Class: TNS::Color::Variant
- Extended by:
- Forwardable
- Defined in:
- lib/tns/color/variant.rb
Overview
A variant of a color, which could be either a tint or a shade.
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
-
#index ⇒ Object
Return the step relative to base color.
-
#initialize(color, step) ⇒ Variant
constructor
A new instance of Variant.
-
#to_hex ⇒ Object
Change the internal color representation to Hex.
-
#to_hsl ⇒ Object
Change the internal color representation to HSL.
Methods inherited from Base
Constructor Details
#initialize(color, step) ⇒ Variant
Returns a new instance of Variant.
15 16 17 18 19 |
# File 'lib/tns/color/variant.rb', line 15 def initialize(color, step) @color = color @step = step super() end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
11 12 13 |
# File 'lib/tns/color/variant.rb', line 11 def color @color end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
11 12 13 |
# File 'lib/tns/color/variant.rb', line 11 def step @step end |
Instance Method Details
#index ⇒ Object
Return the step relative to base color. Step 0 has in index of 5, tints and shades have indices relative to that.
35 36 37 |
# File 'lib/tns/color/variant.rb', line 35 def index raise NotImplementedError("Implement this for shades or tints") end |
#to_hex ⇒ Object
Change the internal color representation to Hex
22 23 24 25 |
# File 'lib/tns/color/variant.rb', line 22 def to_hex @color = @color.to_hex self end |
#to_hsl ⇒ Object
Change the internal color representation to HSL
28 29 30 31 |
# File 'lib/tns/color/variant.rb', line 28 def to_hsl @color = @color.to_hsl self end |