Module: ColorizedText
- Defined in:
- lib/colorized_text.rb
Overview
Colorizes text with ASCII colors.
Usage:
include ColorizedText
puts green "OK" # => green output
puts bold "Running... # => bold output
puts bold green "OK!!!" # => bold green output
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:
30 31 32 |
# File 'lib/colorized_text.rb', line 30 def bold(text) colorize(text, 1) end |
#colorize(text, code) ⇒ Object
Colorize text using ASCII color code
10 11 12 |
# File 'lib/colorized_text.rb', line 10 def colorize(text, code) "\033[#{code}m#{text}\033[0m" end |
#green(text) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/colorized_text.rb', line 20 def green(text) colorize(text, 32) end |
#red(text) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/colorized_text.rb', line 25 def red(text) colorize(text, 31) end |
#yellow(text) ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/colorized_text.rb', line 15 def yellow(text) colorize(text, 33) end |