Class: Rainbow::Color::RGB
- Inherits:
-
Indexed
- Object
- Rainbow::Color
- Indexed
- Rainbow::Color::RGB
- Defined in:
- lib/rainbow/color.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Attributes inherited from Indexed
Attributes inherited from Rainbow::Color
Class Method Summary collapse
Instance Method Summary collapse
- #codes ⇒ Object
-
#initialize(ground, *values) ⇒ RGB
constructor
A new instance of RGB.
Methods inherited from Rainbow::Color
Constructor Details
#initialize(ground, *values) ⇒ RGB
Returns a new instance of RGB.
97 98 99 100 101 102 103 104 |
# File 'lib/rainbow/color.rb', line 97 def initialize(ground, *values) if values.min < 0 || values.max > 255 fail ArgumentError, "RGB value outside 0-255 range" end super(ground, 8) @r, @g, @b = values end |
Instance Attribute Details
#b ⇒ Object (readonly)
Returns the value of attribute b.
91 92 93 |
# File 'lib/rainbow/color.rb', line 91 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
91 92 93 |
# File 'lib/rainbow/color.rb', line 91 def g @g end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
91 92 93 |
# File 'lib/rainbow/color.rb', line 91 def r @r end |
Class Method Details
.to_ansi_domain(value) ⇒ Object
93 94 95 |
# File 'lib/rainbow/color.rb', line 93 def self.to_ansi_domain(value) (6 * (value / 256.0)).to_i end |
Instance Method Details
#codes ⇒ Object
106 107 108 |
# File 'lib/rainbow/color.rb', line 106 def codes super + [5, code_from_rgb] end |