<commit_before>module Mimey
  # his class represents the Game Boy MMU
  class LcdScreen
    WIDTH = 160
    HEIGHT = 10 #144
    COLORS = [107, 100, 47, 40] # lightest to darkest

    def initialize
      @screen = (WIDTH * HEIGHT).times.map { 0 }
    end

    def render
      @screen.each_with_index do |color, pos|
        print_pixel(color)
        # print "."
        print "\n" if (pos + 1) % WIDTH == 0
      end
    end

    def []=(coords, color)
      x, y = coords
      if x < WIDTH and y < HEIGHT
        @screen[y * WIDTH + x] = color
      end
    end

    private
    # https://github.com/fazibear/colorize/blob/master/lib/colorize.rb
    # http://misc.flogisoft.com/bash/tip_colors_and_formatting
    def print_pixel(color)
      code = COLORS[color]
      print "\e[49m\e[#{code}m \e[49m"
    end
  end
end<commit_msg>Using color names<commit_after>module Mimey
  # his class represents the Game Boy MMU
  class LcdScreen
    WIDTH = 160
    HEIGHT = 10 #144
    COLORS = [107, 100, 47, 40] # lightest to darkest
    COLOR_NAMES = [:white, :light_gray, :dark_gray, :black]

    def initialize
      @screen = (WIDTH * HEIGHT).times.map { 0 }
    end

    def render
      @screen.each_with_index do |color, pos|
        print_pixel(color)
        # print "."
        print "\n" if (pos + 1) % WIDTH == 0
      end
    end

    def []=(coords, color)
      return unless color
      color_code = COLORS[COLOR_NAMES.index(color)]
      x, y = coords
      if x < WIDTH and y < HEIGHT
        @screen[y * WIDTH + x] = color_code
      end
    end

    private
    # https://github.com/fazibear/colorize/blob/master/lib/colorize.rb
    # http://misc.flogisoft.com/bash/tip_colors_and_formatting
    def print_pixel(color)
      code = COLORS[color]
      print "\e[49m\e[#{code}m \e[49m"
    end
  end
end
{'fraction_non_alphanumeric': 0.11324903793293019, 'fraction_numerical': 0.02748763056624519, 'mean_word_length': 2.1707317073170733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '479056', 'n_tokens_mistral': 707, 'n_tokens_neox': 639, 'n_words': 169}