Class: Colordom::Color
- Inherits:
-
Object
- Object
- Colordom::Color
- Defined in:
- lib/colordom/color.rb
Overview
Color object with RGB and HEX values implemented in Rust.
Instance Attribute Summary collapse
-
#b ⇒ Integer
readonly
Blue color value.
-
#g ⇒ Integer
readonly
Green color value.
-
#r ⇒ Integer
readonly
Red color value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare with other color value.
-
#hex ⇒ String
(also: #to_hex)
Get the hex representation of the color.
-
#initialize(r, g, b) ⇒ Color
constructor
A new instance of Color.
-
#rgb ⇒ Array<Integer>
(also: #to_rgb)
Get the RGB representation of the color.
Constructor Details
Instance Attribute Details
#b ⇒ Integer (readonly)
Blue color value.
|
# File 'lib/colordom/color.rb', line 18
|
#g ⇒ Integer (readonly)
Green color value.
|
# File 'lib/colordom/color.rb', line 14
|
#r ⇒ Integer (readonly)
Red color value.
|
# File 'lib/colordom/color.rb', line 10
|
Instance Method Details
#==(other) ⇒ Boolean
Compare with other color value.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/colordom/color.rb', line 36 def ==(other) case other when Array rgb == other when String hex == other when self.class rgb == other.rgb else false end end |
#hex ⇒ String Also known as: to_hex
Get the hex representation of the color.
|
# File 'lib/colordom/color.rb', line 27
|
#rgb ⇒ Array<Integer> Also known as: to_rgb
Get the RGB representation of the color.
|
# File 'lib/colordom/color.rb', line 22
|