Module: ColorizedText
- Defined in:
- lib/colorized_text.rb
Overview
Colorizes text with ASCII colors.
Instance Method Summary collapse
-
#bold(text) ⇒ Object
:nodoc:.
-
#colorize(text, code) ⇒ Object
Colorize text using ASCII color code.
-
#green(text) ⇒ Object
:nodoc:.
-
#red(text) ⇒ Object
:nodoc:.
-
#yellow(text) ⇒ Object
:nodoc:.
Instance Method Details
#bold(text) ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/colorized_text.rb', line 31 def bold(text) colorize(text, 1) end |
#colorize(text, code) ⇒ Object
Colorize text using ASCII color code
11 12 13 |
# File 'lib/colorized_text.rb', line 11 def colorize(text, code) "\033[#{code}m#{text}\033[0m" end |
#green(text) ⇒ Object
:nodoc:
21 22 23 |
# File 'lib/colorized_text.rb', line 21 def green(text) colorize(text, 32) end |
#red(text) ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/colorized_text.rb', line 26 def red(text) colorize(text, 31) end |
#yellow(text) ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/colorized_text.rb', line 16 def yellow(text) colorize(text, 33) end |