Class: String

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

Overview

monkeypatch String for colors

Instance Method Summary collapse

Instance Method Details

#blueObject



53
54
55
# File 'lib/constancy.rb', line 53

def blue
  colorize(34)
end

#boldObject



69
70
71
# File 'lib/constancy.rb', line 69

def bold
  colorize(1,22)
end

#colorize(s, e = 0) ⇒ Object



41
42
43
# File 'lib/constancy.rb', line 41

def colorize(s,e=0)
  Constancy.config.color? ? "\e[#{s}m#{self}\e[#{e}m" : self
end

#cyanObject



61
62
63
# File 'lib/constancy.rb', line 61

def cyan
  colorize(36)
end

#grayObject



65
66
67
# File 'lib/constancy.rb', line 65

def gray
  colorize(37)
end

#greenObject



49
50
51
# File 'lib/constancy.rb', line 49

def green
  colorize(32)
end

#magentaObject



57
58
59
# File 'lib/constancy.rb', line 57

def magenta
  colorize(35)
end

#redObject



45
46
47
# File 'lib/constancy.rb', line 45

def red
  colorize(31)
end