Class: ColorDiff::Color::RGB
- Inherits:
-
Object
- Object
- ColorDiff::Color::RGB
- Defined in:
- lib/color_diff/color/rgb.rb
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.
Instance Method Summary collapse
-
#initialize(r = 0, g = 0, b = 0) ⇒ RGB
constructor
A new instance of RGB.
- #to_lab ⇒ Object
- #to_s ⇒ Object
- #to_xyz ⇒ Object
Constructor Details
#initialize(r = 0, g = 0, b = 0) ⇒ RGB
6 7 8 9 10 |
# File 'lib/color_diff/color/rgb.rb', line 6 def initialize(r = 0, g = 0, b = 0) @r = r @g = g @b = b end |
Instance Attribute Details
#b ⇒ Object (readonly)
Returns the value of attribute b.
4 5 6 |
# File 'lib/color_diff/color/rgb.rb', line 4 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
4 5 6 |
# File 'lib/color_diff/color/rgb.rb', line 4 def g @g end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
4 5 6 |
# File 'lib/color_diff/color/rgb.rb', line 4 def r @r end |
Instance Method Details
#to_lab ⇒ Object
16 17 18 |
# File 'lib/color_diff/color/rgb.rb', line 16 def to_lab to_xyz.to_lab end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/color_diff/color/rgb.rb', line 20 def to_s "R#{@r}G#{@g}B#{@b}" end |
#to_xyz ⇒ Object
12 13 14 |
# File 'lib/color_diff/color/rgb.rb', line 12 def to_xyz Xyz.from_rgb(self) end |