Class: ColorDiff::Color::RGB

Inherits:
Object
  • Object
show all
Defined in:
lib/color_diff/color/rgb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bObject (readonly)

Returns the value of attribute b.



4
5
6
# File 'lib/color_diff/color/rgb.rb', line 4

def b
  @b
end

#gObject (readonly)

Returns the value of attribute g.



4
5
6
# File 'lib/color_diff/color/rgb.rb', line 4

def g
  @g
end

#rObject (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_labObject



16
17
18
# File 'lib/color_diff/color/rgb.rb', line 16

def to_lab
  to_xyz.to_lab
end

#to_sObject



20
21
22
# File 'lib/color_diff/color/rgb.rb', line 20

def to_s
  "R#{@r}G#{@g}B#{@b}"
end

#to_xyzObject



12
13
14
# File 'lib/color_diff/color/rgb.rb', line 12

def to_xyz
  Xyz.from_rgb(self)
end