Class: String

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

Constant Summary collapse

COLOURS =

The Main Toc Driver.

Example:

puts 'Hello World'.red
puts 'Hello World'.red_on_black
puts 'Hello World'.red_on_black.underline
{
  'black'      => 30,
  'red'        => 31,
  'green'      => 32,
  'yellow'     => 33,
  'purple'     => 34,
  'pink'       => 35,
  'light_blue' => 36
}
STYLES =
{
  'bold'      => 1,
  'underline' => 4,
  'inverse'  => 7
}

Instance Method Summary collapse

Instance Method Details

#change(colour_code, options = {}) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/toc.rb', line 44

def change(colour_code, options = {})
  if options[:background] && COLOURS[options[:background]]
    "\e[#{colour_code};#{COLOURS[options[:background]] + 10}m#{self}\e[0m"
  else
    "\e[#{colour_code}m#{self}\e[0m"
  end
end