Sha256: 160bf14efe6c21e273ebbfad1af34300ba1a10b85aff79a20694fa5eddf027f0

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

module AnsiColor
  module String
    FOREGROUND_COLORS.each do |name, code|
      define_method name do
        "#{E}#{code}m#{self}#{RESET}"
      end
    end

    BACKGROUND_COLORS.each do |name, code|
      define_method "#{name}_background" do
        "#{E}0;#{code}m#{self}#{RESET}"
      end
    end

    FOREGROUND_COLORS.each do |fg_name, fg_code|
      BACKGROUND_COLORS.each do |bg_name, bg_code|
        define_method "#{fg_name}_on_#{bg_name}" do
          "#{E}#{fg_code};#{bg_code}m#{self}#{RESET}"
        end
      end
    end

    EFFECTS.each do |name, code|
      define_method name do
        "#{E}#{code}m#{self}#{E}0m"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
comboy-ansi_color-0.4.2 lib/ansi_color/string.rb
jcf-ansi_color-0.4.1 lib/ansi_color/string.rb
jcf-ansi_color-0.4.2 lib/ansi_color/string.rb