Class: Thor::Shell::Color
- Defined in:
- lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/color.rb
Overview
Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods.
Constant Summary collapse
- CLEAR =
Embed in a String to clear all previous ANSI sequences.
"\e[0m"
- BOLD =
The start of an ANSI bold sequence.
"\e[1m"
- BLACK =
Set the terminal’s foreground ANSI color to black.
"\e[30m"
- RED =
Set the terminal’s foreground ANSI color to red.
"\e[31m"
- GREEN =
Set the terminal’s foreground ANSI color to green.
"\e[32m"
- YELLOW =
Set the terminal’s foreground ANSI color to yellow.
"\e[33m"
- BLUE =
Set the terminal’s foreground ANSI color to blue.
"\e[34m"
- MAGENTA =
Set the terminal’s foreground ANSI color to magenta.
"\e[35m"
- CYAN =
Set the terminal’s foreground ANSI color to cyan.
"\e[36m"
- WHITE =
Set the terminal’s foreground ANSI color to white.
"\e[37m"
- ON_BLACK =
Set the terminal’s background ANSI color to black.
"\e[40m"
- ON_RED =
Set the terminal’s background ANSI color to red.
"\e[41m"
- ON_GREEN =
Set the terminal’s background ANSI color to green.
"\e[42m"
- ON_YELLOW =
Set the terminal’s background ANSI color to yellow.
"\e[43m"
- ON_BLUE =
Set the terminal’s background ANSI color to blue.
"\e[44m"
- ON_MAGENTA =
Set the terminal’s background ANSI color to magenta.
"\e[45m"
- ON_CYAN =
Set the terminal’s background ANSI color to cyan.
"\e[46m"
- ON_WHITE =
Set the terminal’s background ANSI color to white.
"\e[47m"
Instance Attribute Summary
Attributes inherited from Basic
Instance Method Summary collapse
-
#set_color(string, color, bold = false) ⇒ Object
Set color by using a string or one of the defined constants.
Methods inherited from Basic
#ask, #error, #file_collision, #initialize, #no?, #print_table, #say, #say_status, #yes?
Constructor Details
This class inherits a constructor from Thor::Shell::Basic
Instance Method Details
#set_color(string, color, bold = false) ⇒ Object
Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.
53 54 55 56 57 |
# File 'lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/color.rb', line 53 def set_color(string, color, bold=false) color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) bold = bold ? BOLD : "" "#{bold}#{color}#{string}#{CLEAR}" end |