Class: Chroma::ColorModes::Rgb

Inherits:
Object
  • Object
show all
Defined in:
lib/chroma/color_modes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, g, b, a = 1) ⇒ Rgb

Returns a new instance of Rgb.

Parameters:

  • r (Numeric)
  • g (Numeric)
  • b (Numeric)
  • a (Numeric) (defaults to: 1)


8
9
10
# File 'lib/chroma/color_modes.rb', line 8

def initialize(r, g, b, a = 1)
  @r, @g, @b, @a = r, g, b, a
end

Instance Attribute Details

#aObject

Returns the value of attribute a.



2
3
4
# File 'lib/chroma/color_modes.rb', line 2

def a
  @a
end

#bObject

Returns the value of attribute b.



2
3
4
# File 'lib/chroma/color_modes.rb', line 2

def b
  @b
end

#gObject

Returns the value of attribute g.



2
3
4
# File 'lib/chroma/color_modes.rb', line 2

def g
  @g
end

#rObject

Returns the value of attribute r.



2
3
4
# File 'lib/chroma/color_modes.rb', line 2

def r
  @r
end

Instance Method Details

#to_aArray<Numeric> Also known as: to_ary

Returns the values r, g, b, and a as an array.

Returns:

  • (Array<Numeric>)


15
16
17
# File 'lib/chroma/color_modes.rb', line 15

def to_a
  [@r, @g, @b, @a]
end