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
64 65 66 |
# File 'lib/constancy.rb', line 64 def blue colorize(34) end |
#bold ⇒ Object
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 |
#cyan ⇒ Object
72 73 74 |
# File 'lib/constancy.rb', line 72 def cyan colorize(36) end |
#gray ⇒ Object
76 77 78 |
# File 'lib/constancy.rb', line 76 def gray colorize(37) end |
#green ⇒ Object
60 61 62 |
# File 'lib/constancy.rb', line 60 def green colorize(32) end |
#magenta ⇒ Object
68 69 70 |
# File 'lib/constancy.rb', line 68 def magenta colorize(35) end |
#red ⇒ Object
56 57 58 |
# File 'lib/constancy.rb', line 56 def red colorize(31) end |
#trim_path ⇒ Object
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 |