Class: Shoes::Color::HexConverter
- Inherits:
-
Object
- Object
- Shoes::Color::HexConverter
- 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
-
#initialize(hex) ⇒ HexConverter
constructor
A new instance of HexConverter.
- #to_rgb ⇒ Object
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_rgb ⇒ Object
13 14 15 |
# File 'shoes-core/lib/shoes/color/hex_converter.rb', line 13 def to_rgb [@red, @green, @blue] end |