module CommandKit::Colors::ANSI
Applies ANSI
formatting to text.
Constants
- BLACK
ANSI
color code for black- BLUE
ANSI
color code for blue- BOLD
ANSI
code for bold text- CLEAR
@see
RESET
- CYAN
ANSI
color code for cyan- GREEN
ANSI
color code for green- MAGENTA
ANSI
color code for magenta- ON_BLACK
ANSI
color code for background color black@since 0.2.0
- ON_BLUE
ANSI
color code for background color blue@since 0.2.0
- ON_CYAN
ANSI
color code for background color cyan@since 0.2.0
- ON_GREEN
ANSI
color code for background color green@since 0.2.0
- ON_MAGENTA
ANSI
color code for background color megenta@since 0.2.0
- ON_RED
ANSI
color code for background color red@since 0.2.0
- ON_WHITE
ANSI
color code for background color white@since 0.2.0
- ON_YELLOW
ANSI
color code for background color yellow@since 0.2.0
- RED
ANSI
color code for red- RESET
ANSI
reset code- RESET_BG
ANSI
color for the default background color@since 0.2.0
- RESET_COLOR
ANSI
color for the default foreground color- RESET_INTENSITY
ANSI
code to disable boldness- WHITE
ANSI
color code for white- YELLOW
ANSI
color code for yellow
Public Instance Methods
Sets the text color to black.
@param [String, nil] string
An optional string.
@return [String, BLACK]
The colorized string or just {BLACK} if no arguments were given.
@see BLACK
@api public
# File lib/command_kit/colors.rb, line 183 def black(string=nil) if string then "#{BLACK}#{string}#{RESET_COLOR}" else BLACK end end
Sets the text color to blue.
@param [String, nil] string
An optional string.
@return [String, BLUE]
The colorized string or just {BLUE} if no arguments were given.
@see BLUE
@api public
# File lib/command_kit/colors.rb, line 259 def blue(string=nil) if string then "#{BLUE}#{string}#{RESET_COLOR}" else BLUE end end
Bolds the text.
@param [String, nil] string
An optional string.
@return [String, BOLD]
The bolded string or just {BOLD} if no arguments were given.
@see BOLD
@api public
# File lib/command_kit/colors.rb, line 164 def bold(string=nil) if string then "#{BOLD}#{string}#{RESET_INTENSITY}" else BOLD end end
@see reset
@api public
# File lib/command_kit/colors.rb, line 147 def clear reset end
Sets the text color to cyan.
@param [String, nil] string
An optional string.
@return [String, CYAN]
The colorized string or just {CYAN} if no arguments were given.
@see CYAN
@api public
# File lib/command_kit/colors.rb, line 297 def cyan(string=nil) if string then "#{CYAN}#{string}#{RESET_COLOR}" else CYAN end end
Sets the text color to green.
@param [String, nil] string
An optional string.
@return [String, GREEN]
The colorized string or just {GREEN} if no arguments were given.
@see GREEN
@api public
# File lib/command_kit/colors.rb, line 221 def green(string=nil) if string then "#{GREEN}#{string}#{RESET_COLOR}" else GREEN end end
Sets the text color to magenta.
@param [String, nil] string
An optional string.
@return [String, MAGENTA]
The colorized string or just {MAGENTA} if no arguments were given.
@see MAGENTA
@api public
# File lib/command_kit/colors.rb, line 278 def magenta(string=nil) if string then "#{MAGENTA}#{string}#{RESET_COLOR}" else MAGENTA end end
Sets the background color to black.
@param [String, nil] string
An optional string.
@return [String, ON_BLACK
]
The colorized string or just {ON_BLACK} if no arguments were given.
@see ON_BLACK
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 337 def on_black(string=nil) if string then "#{ON_BLACK}#{string}#{RESET_BG}" else ON_BLACK end end
Sets the background color to blue.
@param [String, nil] string
An optional string.
@return [String, ON_BLUE
]
The colorized string or just {ON_BLUE} if no arguments were given.
@see ON_BLUE
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 421 def on_blue(string=nil) if string then "#{ON_BLUE}#{string}#{RESET_BG}" else ON_BLUE end end
Sets the background color to cyan.
@param [String, nil] string
An optional string.
@return [String, ON_CYAN
]
The colorized string or just {ON_CYAN} if no arguments were given.
@see ON_CYAN
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 463 def on_cyan(string=nil) if string then "#{ON_CYAN}#{string}#{RESET_BG}" else ON_CYAN end end
Sets the background color to green.
@param [String, nil] string
An optional string.
@return [String, ON_GREEN
]
The colorized string or just {ON_GREEN} if no arguments were given.
@see ON_GREEN
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 379 def on_green(string=nil) if string then "#{ON_GREEN}#{string}#{RESET_BG}" else ON_GREEN end end
Sets the background color to magenta.
@param [String, nil] string
An optional string.
@return [String, ON_MAGENTA
]
The colorized string or just {ON_MAGENTA} if no arguments were given.
@see ON_MAGENTA
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 442 def on_magenta(string=nil) if string then "#{ON_MAGENTA}#{string}#{RESET_BG}" else ON_MAGENTA end end
Sets the background color to red.
@param [String, nil] string
An optional string.
@return [String, ON_RED
]
The colorized string or just {ON_RED} if no arguments were given.
@see ON_RED
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 358 def on_red(string=nil) if string then "#{ON_RED}#{string}#{RESET_BG}" else ON_RED end end
Sets the background color to white.
@param [String, nil] string
An optional string.
@return [String, ON_WHITE
]
The colorized string or just {ON_WHITE} if no arguments were given.
@see ON_WHITE
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 484 def on_white(string=nil) if string then "#{ON_WHITE}#{string}#{RESET_BG}" else ON_WHITE end end
Sets the background color to yellow.
@param [String, nil] string
An optional string.
@return [String, ON_YELLOW
]
The colorized string or just {ON_YELLOW} if no arguments were given.
@see ON_YELLOW
@api public
@since 0.2.0
# File lib/command_kit/colors.rb, line 400 def on_yellow(string=nil) if string then "#{ON_YELLOW}#{string}#{RESET_BG}" else ON_YELLOW end end
Sets the text color to red.
@param [String, nil] string
An optional string.
@return [String, RED]
The colorized string or just {RED} if no arguments were given.
@see RED
@api public
# File lib/command_kit/colors.rb, line 202 def red(string=nil) if string then "#{RED}#{string}#{RESET_COLOR}" else RED end end
Resets text formatting.
@return [RESET]
@see RESET
@api public
# File lib/command_kit/colors.rb, line 138 def reset RESET end
Sets the text color to white.
@param [String, nil] string
An optional string.
@return [String, WHITE]
The colorized string or just {WHITE} if no arguments were given.
@see WHITE
@api public
# File lib/command_kit/colors.rb, line 316 def white(string=nil) if string then "#{WHITE}#{string}#{RESET_COLOR}" else WHITE end end
Sets the text color to yellow.
@param [String, nil] string
An optional string.
@return [String, YELLOW]
The colorized string or just {YELLOW} if no arguments were given.
@see YELLOW
@api public
# File lib/command_kit/colors.rb, line 240 def yellow(string=nil) if string then "#{YELLOW}#{string}#{RESET_COLOR}" else YELLOW end end