class String

monkeypatch String for display prettiness

Public Instance Methods

blue() click to toggle source
# File lib/constancy.rb, line 66
def blue
  colorize(34)
end
bold() click to toggle source
# File lib/constancy.rb, line 82
def bold
  colorize(1,22)
end
colorize(s,e=0) click to toggle source
# File lib/constancy.rb, line 54
def colorize(s,e=0)
  Constancy.config.color? ? "\e[#{s}m#{self}\e[#{e}m" : self
end
cyan() click to toggle source
# File lib/constancy.rb, line 74
def cyan
  colorize(36)
end
gray() click to toggle source
# File lib/constancy.rb, line 78
def gray
  colorize(37)
end
green() click to toggle source
# File lib/constancy.rb, line 62
def green
  colorize(32)
end
magenta() click to toggle source
# File lib/constancy.rb, line 70
def magenta
  colorize(35)
end
red() click to toggle source
# File lib/constancy.rb, line 58
def red
  colorize(31)
end
trim_path() click to toggle source

trim_path replaces the HOME directory on an absolute path with '~'

# File lib/constancy.rb, line 50
def trim_path
  self.sub(%r(^#{ENV['HOME']}), '~')
end