Class: Sickill::Rainbow::AnsiColor
- Inherits:
-
Object
- Object
- Sickill::Rainbow::AnsiColor
- Defined in:
- lib/ansi_color.rb
Overview
Retrieve ANSI color code from a color name, an html color or an RGB color
Instance Method Summary collapse
-
#code ⇒ Object
Get the ANSI color code.
-
#initialize(ground, *color) ⇒ AnsiColor
constructor
ground
is one of :foreground, :backgroundcolor
is one of this 3 formats: name, html, rgb.
Constructor Details
#initialize(ground, *color) ⇒ AnsiColor
ground
is one of :foreground, :background color
is one of this 3 formats: name, html, rgb
12 13 14 15 16 17 18 19 20 |
# File 'lib/ansi_color.rb', line 12 def initialize(ground, *color) @ground = ground if color.size == 1 @color = color.first else @color = color end end |
Instance Method Details
#code ⇒ Object
Get the ANSI color code.
23 24 25 26 27 28 29 |
# File 'lib/ansi_color.rb', line 23 def code case @color when Symbol then code_from_name when String then code_from_html when Array then code_from_rgb end end |