Class: Yay::ColourWheel
- Inherits:
-
Object
- Object
- Yay::ColourWheel
- Defined in:
- lib/yay/colour_wheel.rb
Overview
the colour wheel contains all the constants needed to create coloured text there are also a few static helper methods to make rendering text easier
Constant Summary collapse
- MISC =
commands. support varies
{ :reset => 0, :bright => 1, :dim => 2, :underscore => 4, :blink => 5, :reverse => 7, :hidden => 8, :normal => 0, #alias :invert => 7, #alias :inverted => 7, #alias :underscored => 4, #alias :bold => 1, #alias }
- FG =
foreground colours
{ :black => 30, :red => 31, :green => 32, :yellow => 33, :blue => 34, :magenta => 35, :cyan => 36, :white => 37, }
- BG =
background colours
{ :black => 40, :red => 41, :green => 42, :yellow => 43, :blue => 44, :magenta => 45, :cyan => 46, :white => 47 }
Class Method Summary collapse
-
.all_names ⇒ Object
return all the possible colour names the keys are used as string representations by the parser.
-
.begin_colours(colour_numbers) ⇒ Object
ge the string that begins the current colour code.
-
.end_colour ⇒ Object
the command necessary to stop printing with colour.
- .fail ⇒ Object
-
.success ⇒ Object
ge the string that begins the current colour code.
Class Method Details
.all_names ⇒ Object
return all the possible colour names the keys are used as string representations by the parser
49 50 51 52 |
# File 'lib/yay/colour_wheel.rb', line 49 def self.all_names # assume BG and FG have the same keys MISC.keys | FG.keys end |
.begin_colours(colour_numbers) ⇒ Object
ge the string that begins the current colour code
55 56 57 |
# File 'lib/yay/colour_wheel.rb', line 55 def self.begin_colours(colour_numbers) "\033[#{colour_numbers.join(';')}m" end |
.end_colour ⇒ Object
the command necessary to stop printing with colour
60 61 62 |
# File 'lib/yay/colour_wheel.rb', line 60 def self.end_colour "\033[0m" end |
.fail ⇒ Object
69 70 71 |
# File 'lib/yay/colour_wheel.rb', line 69 def self.fail() self.begin_colours([FG[:red]]) end |
.success ⇒ Object
ge the string that begins the current colour code
65 66 67 |
# File 'lib/yay/colour_wheel.rb', line 65 def self.success self.begin_colours([FG[:green]]) end |