Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/lotu/helpers/string.rb
Overview
As saw in a russian comment by ZARATUSTR at: kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/
Instance Method Summary collapse
- #blue ⇒ Object
- #colorize(text, color_code) ⇒ Object
- #dark_blue ⇒ Object
- #dark_green ⇒ Object
- #green ⇒ Object
- #purple ⇒ Object
- #red ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#blue ⇒ Object
9 |
# File 'lib/lotu/helpers/string.rb', line 9 def blue; colorize(self, "\e[1m\e[34m") end |
#colorize(text, color_code) ⇒ Object
12 |
# File 'lib/lotu/helpers/string.rb', line 12 def colorize(text, color_code) "#{color_code}#{text}\e[0m" end |
#dark_blue ⇒ Object
10 |
# File 'lib/lotu/helpers/string.rb', line 10 def dark_blue; colorize(self, "\e[34m") end |
#dark_green ⇒ Object
7 |
# File 'lib/lotu/helpers/string.rb', line 7 def dark_green; colorize(self, "\e[32m") end |
#green ⇒ Object
6 |
# File 'lib/lotu/helpers/string.rb', line 6 def green; colorize(self, "\e[1m\e[32m") end |
#purple ⇒ Object
11 |
# File 'lib/lotu/helpers/string.rb', line 11 def purple; colorize(self, "\e[1m\e[35m") end |
#red ⇒ Object
5 |
# File 'lib/lotu/helpers/string.rb', line 5 def red; colorize(self, "\e[1m\e[31m") end |
#yellow ⇒ Object
8 |
# File 'lib/lotu/helpers/string.rb', line 8 def yellow; colorize(self, "\e[1m\e[33m") end |