Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mmtop/string_colorize.rb

Constant Summary collapse

CODES =
{
  :off       => "\e[0m",
  :bright    => "\e[1m",
  :underline => "\e[4m",
  :blink     => "\e[5m",
  :swap      => "\e[7m",
  :hide      => "\e[8m",

  :black     => "\e[30m",
  :dark_gray => "\e[1;30m",
  :red       => "\e[31m",
  :green     => "\e[32m",
  :yellow    => "\e[33m",
  :blue      => "\e[34m",
  :magenta   => "\e[35m",
  :cyan      => "\e[36m",
  :white     => "\e[37m",
  :default   => "\e[39m",

  :black_background     => "\e[40m",
  :red_background       => "\e[41m",
  :green_background     => "\e[42m",
  :yellow_background    => "\e[43m",
  :blue_background      => "\e[44m",
  :magenta_background   => "\e[45m",
  :cyan_background      => "\e[46m",
  :white_background     => "\e[47m",
  :default_background   => "\e[49m"
}
OFF =

Instance Method Summary collapse

Instance Method Details

#blackObject



83
# File 'lib/mmtop/string_colorize.rb', line 83

def black; colorize(:black); end

#boldObject



82
# File 'lib/mmtop/string_colorize.rb', line 82

def bold; colorize(:bright); end

#colorize(*args) ⇒ Object



73
74
75
76
# File 'lib/mmtop/string_colorize.rb', line 73

def colorize(*args)
  color = args.map { |color| CODES[color] if color.is_a?(Symbol) }.join("")
  ColorString.new(self, color)
end

#colourise(*args) ⇒ Object



78
# File 'lib/mmtop/string_colorize.rb', line 78

def colourise(*args); colorize(*args); end

#dark_grayObject



85
# File 'lib/mmtop/string_colorize.rb', line 85

def dark_gray; colorize(:dark_gray); end

#greenObject



81
# File 'lib/mmtop/string_colorize.rb', line 81

def green; colorize(:green); end

#redObject



80
# File 'lib/mmtop/string_colorize.rb', line 80

def red; colorize(:red); end

#whiteObject



84
# File 'lib/mmtop/string_colorize.rb', line 84

def white; colorize(:white); end