Class: String

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

Overview

monkeypatch String for display prettiness

Instance Method Summary collapse

Instance Method Details

#blueObject



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

def blue
  colorize(34)
end

#boldObject



82
83
84
# File 'lib/constancy.rb', line 82

def bold
  colorize(1,22)
end

#colorize(s, e = 0) ⇒ Object



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

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

#cyanObject



74
75
76
# File 'lib/constancy.rb', line 74

def cyan
  colorize(36)
end

#grayObject



78
79
80
# File 'lib/constancy.rb', line 78

def gray
  colorize(37)
end

#greenObject



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

def green
  colorize(32)
end

#magentaObject



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

def magenta
  colorize(35)
end

#redObject



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

def red
  colorize(31)
end

#trim_pathObject

trim_path replaces the HOME directory on an absolute path with ‘~’



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

def trim_path
  self.sub(%r(^#{ENV['HOME']}), '~')
end