Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/tools/string-colorize.rb

Overview

Adds a number of methods for colorizing output strings

Instance Method Summary collapse

Instance Method Details

#blueObject



20
21
22
# File 'lib/generamba/tools/string-colorize.rb', line 20

def blue
  colorize(34)
end

#colorize(color_code) ⇒ Object



4
5
6
# File 'lib/generamba/tools/string-colorize.rb', line 4

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end

#greenObject



12
13
14
# File 'lib/generamba/tools/string-colorize.rb', line 12

def green
  colorize(32)
end

#redObject



8
9
10
# File 'lib/generamba/tools/string-colorize.rb', line 8

def red
  colorize(31)
end

#yellowObject



16
17
18
# File 'lib/generamba/tools/string-colorize.rb', line 16

def yellow
  colorize(33)
end