Class: TNS::Color::HSL
- Inherits:
-
Object
- Object
- TNS::Color::HSL
- Defined in:
- lib/tns/color/hsl.rb
Overview
HSL is our base representation for color objects.
Instance Attribute Summary collapse
-
#hue ⇒ Object
readonly
Returns the value of attribute hue.
-
#lightness ⇒ Object
readonly
Returns the value of attribute lightness.
-
#saturation ⇒ Object
readonly
Returns the value of attribute saturation.
Instance Method Summary collapse
-
#initialize(rgb) ⇒ HSL
constructor
A new instance of HSL.
- #to_css ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(rgb) ⇒ HSL
Returns a new instance of HSL.
9 10 11 12 |
# File 'lib/tns/color/hsl.rb', line 9 def initialize(rgb) @hue, @saturation, @lightness = from_rgb(rgb) super() end |
Instance Attribute Details
#hue ⇒ Object (readonly)
Returns the value of attribute hue.
7 8 9 |
# File 'lib/tns/color/hsl.rb', line 7 def hue @hue end |
#lightness ⇒ Object (readonly)
Returns the value of attribute lightness.
7 8 9 |
# File 'lib/tns/color/hsl.rb', line 7 def lightness @lightness end |
#saturation ⇒ Object (readonly)
Returns the value of attribute saturation.
7 8 9 |
# File 'lib/tns/color/hsl.rb', line 7 def saturation @saturation end |
Instance Method Details
#to_css ⇒ Object
14 15 16 |
# File 'lib/tns/color/hsl.rb', line 14 def to_css "hsl(#{self})" end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/tns/color/hsl.rb', line 18 def to_s format("%<hue>d %<saturation>d %<lightness>d", hue: @hue, saturation: @saturation, lightness: @lightness) end |