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



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

def blue
  colorize(34)
end

#boldObject



80
81
82
# File 'lib/constancy.rb', line 80

def bold
  colorize(1,22)
end

#colorize(s, e = 0) ⇒ Object



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

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

#cyanObject



72
73
74
# File 'lib/constancy.rb', line 72

def cyan
  colorize(36)
end

#grayObject



76
77
78
# File 'lib/constancy.rb', line 76

def gray
  colorize(37)
end

#greenObject



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

def green
  colorize(32)
end

#magentaObject



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

def magenta
  colorize(35)
end

#redObject



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

def red
  colorize(31)
end

#trim_pathObject

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



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

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