Class: ColorName::Color
- Inherits:
-
Object
- Object
- ColorName::Color
- Defined in:
- lib/color_name/color.rb
Instance Method Summary collapse
- #hsl ⇒ Object
-
#initialize(hex) ⇒ Color
constructor
A new instance of Color.
- #name ⇒ Object
- #rgb ⇒ Object
Constructor Details
#initialize(hex) ⇒ Color
Returns a new instance of Color.
5 6 7 |
# File 'lib/color_name/color.rb', line 5 def initialize(hex) @hex = prepare_hex(hex) end |
Instance Method Details
#hsl ⇒ Object
13 14 15 |
# File 'lib/color_name/color.rb', line 13 def hsl @hsl ||= calculate_hsl end |
#name ⇒ Object
17 18 19 |
# File 'lib/color_name/color.rb', line 17 def name @name ||= find_name end |
#rgb ⇒ Object
9 10 11 |
# File 'lib/color_name/color.rb', line 9 def rgb @rgb ||= [hex[0..1].hex, hex[2..3].hex, hex[4..5].hex] end |