Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ra10ke/monkey_patches.rb
Instance Method Summary collapse
-
#colorize(color_code) ⇒ Object
colorization.
- #green ⇒ Object
- #red ⇒ Object
-
#strip_comment(markers = ['#', "\n"]) ⇒ String
removes specified markes from string.
- #yellow ⇒ Object
Instance Method Details
#colorize(color_code) ⇒ Object
colorization
5 6 7 |
# File 'lib/ra10ke/monkey_patches.rb', line 5 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end |
#green ⇒ Object
13 14 15 |
# File 'lib/ra10ke/monkey_patches.rb', line 13 def green colorize(32) end |
#red ⇒ Object
9 10 11 |
# File 'lib/ra10ke/monkey_patches.rb', line 9 def red colorize(31) end |
#strip_comment(markers = ['#', "\n"]) ⇒ String
removes specified markes from string.
23 24 25 26 27 |
# File 'lib/ra10ke/monkey_patches.rb', line 23 def strip_comment(markers = ['#', "\n"]) re = Regexp.union(markers) index = (self =~ re) index.nil? ? rstrip : self[0, index].rstrip end |
#yellow ⇒ Object
17 18 19 |
# File 'lib/ra10ke/monkey_patches.rb', line 17 def yellow colorize(33) end |