Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/constancy.rb
Overview
monkeypatch String for display prettiness
Instance Method Summary collapse
- #blue ⇒ Object
- #bold ⇒ Object
- #colorize(s, e = 0) ⇒ Object
- #cyan ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
-
#trim_path ⇒ Object
trim_path replaces the HOME directory on an absolute path with ‘~’.
Instance Method Details
#blue ⇒ Object
66 67 68 |
# File 'lib/constancy.rb', line 66 def blue colorize(34) end |
#bold ⇒ Object
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 |
#cyan ⇒ Object
74 75 76 |
# File 'lib/constancy.rb', line 74 def cyan colorize(36) end |
#gray ⇒ Object
78 79 80 |
# File 'lib/constancy.rb', line 78 def gray colorize(37) end |
#green ⇒ Object
62 63 64 |
# File 'lib/constancy.rb', line 62 def green colorize(32) end |
#magenta ⇒ Object
70 71 72 |
# File 'lib/constancy.rb', line 70 def magenta colorize(35) end |
#red ⇒ Object
58 59 60 |
# File 'lib/constancy.rb', line 58 def red colorize(31) end |
#trim_path ⇒ Object
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 |