Module: Mago::Cli::Colorize
- Included in:
- Formatter
- Defined in:
- lib/mago/cli/colorize.rb
Overview
Provides methods to colorize strings with ANSI colors.
Instance Method Summary collapse
-
#colorize(text, color_code) ⇒ String
Colorize text using a passed code.
-
#green(text) ⇒ Object
:nodoc:.
-
#pink(text) ⇒ Object
:nodoc:.
-
#red(text) ⇒ Object
:nodoc:.
-
#yellow(text) ⇒ Object
:nodoc:.
Instance Method Details
#colorize(text, color_code) ⇒ String
Colorize text using a passed code
11 12 13 |
# File 'lib/mago/cli/colorize.rb', line 11 def colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end |
#green(text) ⇒ Object
:nodoc:
21 22 23 |
# File 'lib/mago/cli/colorize.rb', line 21 def green(text) colorize(text, 32) end |
#pink(text) ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/mago/cli/colorize.rb', line 31 def pink(text) colorize(text, 35) end |
#red(text) ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/mago/cli/colorize.rb', line 16 def red(text) colorize(text, 31) end |
#yellow(text) ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/mago/cli/colorize.rb', line 26 def yellow(text) colorize(text, 33) end |