class CLI::UI::Color
Constants
- BLUE
default blue is low-contrast against black in some default terminal color scheme
- BOLD
- CYAN
- GRAY
240 is very dark gray; 255 is very light gray. 244 is somewhat dark.
- GREEN
- MAGENTA
- MAP
- RED
- RESET
- WHITE
- YELLOW
Attributes
code[R]
name[R]
sgr[R]
Public Class Methods
available()
click to toggle source
All available colors by name
# File lib/cli/ui/color.rb, line 79 def self.available MAP.keys end
lookup(name)
click to toggle source
Looks up a color code by name
Raises¶ ↑
Raises a InvalidColorName
if the color is not available You likely need to add it to the MAP
or you made a typo
Returns¶ ↑
Returns a color code
# File lib/cli/ui/color.rb, line 71 def self.lookup(name) MAP.fetch(name) rescue KeyError raise InvalidColorName, name end
new(sgr, name)
click to toggle source
Creates a new color mapping Signatures can be found here: en.wikipedia.org/wiki/ANSI_escape_code#Colors
Attributes¶ ↑
-
sgr
- The color signature -
name
- The name of the color
# File lib/cli/ui/color.rb, line 17 def initialize(sgr, name) @sgr = sgr @code = CLI::UI::ANSI.sgr(sgr) @name = name end