Sha256: a4b7e52bd3b69ea7bed0c2f26fd5e19960ef45e6a6cb61832d2b6a6c621fb4d6

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

class String

  types = {
    :bold => "\e[1m",
    :underline => "\e[4m",
    :black => "\e[30m", 
    :red => "\e[31m",
    :green => "\e[32m",
    :yellow => "\e[33m",
    :blue => "\e[34m",
    :magenta => "\e[35m",
    :cyan => "\e[36m", 
    :white => "\e[37m", 
  }

  types.each do |name, color_code|
    define_method(name) do
      @@colorize ? "#{color_code}#{self}\e[0m" : self
    end
  end

  class << self
    @@colorize = false
    def colorize
      @@colorize = true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logbox-0.2.10 lib/logbox/ansi_colors.rb