Class: Shoes::Color::HexConverter

Inherits:
Object
  • Object
show all
Defined in:
shoes-core/lib/shoes/color/hex_converter.rb

Constant Summary collapse

HEX_REGEX =
/^#?(([0-9a-f]{3}){1,2})$/i

Instance Method Summary collapse

Constructor Details

#initialize(hex) ⇒ HexConverter

Returns a new instance of HexConverter.



8
9
10
11
# File 'shoes-core/lib/shoes/color/hex_converter.rb', line 8

def initialize(hex)
  @hex = validate(hex) || raise(ArgumentError, "Bad hex color: #{hex}")
  @red, @green, @blue = hex_to_rgb(pad_if_necessary(@hex))
end

Instance Method Details

#to_rgbObject



13
14
15
# File 'shoes-core/lib/shoes/color/hex_converter.rb', line 13

def to_rgb
  [@red, @green, @blue]
end