Class: ColorName::Color

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

Instance Method Summary collapse

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

#hslObject



13
14
15
# File 'lib/color_name/color.rb', line 13

def hsl
  @hsl ||= calculate_hsl
end

#nameObject



17
18
19
# File 'lib/color_name/color.rb', line 17

def name
  @name ||= find_name
end

#rgbObject



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