Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/listing.rb
Overview
add colors to String class
Instance Method Summary collapse
- #blue ⇒ Object
- #colorize(code) ⇒ Object
- #cyan ⇒ Object
- #green ⇒ Object
- #purple ⇒ Object
-
#red ⇒ Object
I tried to put “define_method” in a loop but it was having none of it Please accept my humble apologies.
- #yellow ⇒ Object
Instance Method Details
#blue ⇒ Object
18 |
# File 'lib/listing.rb', line 18 def blue; self.colorize(34);end |
#colorize(code) ⇒ Object
7 8 9 10 11 |
# File 'lib/listing.rb', line 7 def colorize(code) "\e[0;#{code.to_s}m#{self}\e[0m" # self end |
#cyan ⇒ Object
20 |
# File 'lib/listing.rb', line 20 def cyan; self.colorize(36);end |
#green ⇒ Object
16 |
# File 'lib/listing.rb', line 16 def green; self.colorize(32);end |
#purple ⇒ Object
19 |
# File 'lib/listing.rb', line 19 def purple; self.colorize(35);end |
#red ⇒ Object
I tried to put “define_method” in a loop but it was having none of it Please accept my humble apologies
15 |
# File 'lib/listing.rb', line 15 def red; self.colorize(31);end |
#yellow ⇒ Object
17 |
# File 'lib/listing.rb', line 17 def yellow; self.colorize(33);end |