Class: CLI::UI::Color
Defined Under Namespace
Classes: InvalidColorName
Constant Summary collapse
- RED =
new('31', :red)
- GREEN =
new('32', :green)
- YELLOW =
new('33', :yellow)
- BLUE =
default blue is low-contrast against black in some default terminal color scheme
new('94', :blue)
- MAGENTA =
new('35', :magenta)
- CYAN =
new('36', :cyan)
- RESET =
new('0', :reset)
- BOLD =
new('1', :bold)
- WHITE =
new('97', :white)
- GRAY =
240 is very dark gray; 255 is very light gray. 244 is somewhat dark.
new('38;5;244', :gray)
- ORANGE =
Using color 214 from the 256-color palette for a more distinct orange
new('38;5;214', :orange)
- MAP =
{ red: RED, green: GREEN, yellow: YELLOW, blue: BLUE, magenta: MAGENTA, cyan: CYAN, reset: RESET, bold: BOLD, gray: GRAY, }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sgr ⇒ Object
readonly
Returns the value of attribute sgr.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sgr, name) ⇒ Color
constructor
A new instance of Color.
Methods included from T::Sig
Constructor Details
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
12 13 14 |
# File 'lib/cli/ui/color.rb', line 12 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/cli/ui/color.rb', line 15 def name @name end |
#sgr ⇒ Object (readonly)
Returns the value of attribute sgr.
12 13 14 |
# File 'lib/cli/ui/color.rb', line 12 def sgr @sgr end |
Class Method Details
.available ⇒ Object
100 101 102 |
# File 'lib/cli/ui/color.rb', line 100 def available MAP.keys end |
.lookup(name) ⇒ Object
91 92 93 94 95 |
# File 'lib/cli/ui/color.rb', line 91 def lookup(name) MAP.fetch(name.to_sym) rescue KeyError raise InvalidColorName, name.to_sym end |