Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/log.rb
Overview
Add ability to output colored text to console e.g.: puts “Hello”.red
Instance Method Summary collapse
- #blue ⇒ Object
- #bold ⇒ Object
- #colorize(color_code) ⇒ Object
- #dark_blue ⇒ Object
- #dark_green ⇒ Object
- #dark_red ⇒ Object
- #green ⇒ Object
- #grey ⇒ Object
- #pur ⇒ Object
- #red ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#blue ⇒ Object
17 |
# File 'lib/log.rb', line 17 def blue; colorize("\e[1m\e[34m"); end |
#bold ⇒ Object
10 |
# File 'lib/log.rb', line 10 def bold; colorize("\e[1m\e[29m"); end |
#colorize(color_code) ⇒ Object
20 21 22 23 |
# File 'lib/log.rb', line 20 def colorize(color_code) # Doesn't work with the Windows prompt... RUBY_PLATFORM =~ /(win|w)32$/ ? to_s : "#{color_code}#{to_s}\e[0m" end |
#dark_blue ⇒ Object
18 |
# File 'lib/log.rb', line 18 def dark_blue; colorize("\e[34m"); end |
#dark_green ⇒ Object
15 |
# File 'lib/log.rb', line 15 def dark_green; colorize("\e[32m"); end |
#dark_red ⇒ Object
13 |
# File 'lib/log.rb', line 13 def dark_red; colorize("\e[31m"); end |
#green ⇒ Object
14 |
# File 'lib/log.rb', line 14 def green; colorize("\e[1m\e[32m"); end |
#grey ⇒ Object
11 |
# File 'lib/log.rb', line 11 def grey; colorize("\e[30m"); end |
#pur ⇒ Object
19 |
# File 'lib/log.rb', line 19 def pur; colorize("\e[1m\e[35m"); end |
#red ⇒ Object
12 |
# File 'lib/log.rb', line 12 def red; colorize("\e[1m\e[31m"); end |
#yellow ⇒ Object
16 |
# File 'lib/log.rb', line 16 def yellow; colorize("\e[1m\e[33m"); end |