Class: Unmagic::Color::Hue
- Inherits:
-
Data
- Object
- Data
- Unmagic::Color::Hue
- Includes:
- Comparable
- Defined in:
- lib/unmagic/color.rb
Overview
Angular unit for hue (0-360 degrees, wrapping)
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#*(other) ⇒ Hue
New hue.
-
#+(other) ⇒ Hue
New hue.
-
#-(other) ⇒ Hue
New hue.
-
#/(other) ⇒ Hue
New hue.
-
#<=>(other) ⇒ Integer?
Comparison result.
-
#abs ⇒ Hue
Absolute value.
- #degrees ⇒ Object
-
#initialize(value:) ⇒ Hue
constructor
A new instance of Hue.
- #to_f ⇒ Object
Constructor Details
#initialize(value:) ⇒ Hue
Returns a new instance of Hue.
181 182 183 |
# File 'lib/unmagic/color.rb', line 181 def initialize(value:) super(value: value.to_f % 360) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value
177 178 179 |
# File 'lib/unmagic/color.rb', line 177 def value @value end |
Instance Method Details
#*(other) ⇒ Hue
Returns New hue.
199 200 201 |
# File 'lib/unmagic/color.rb', line 199 def *(other) self.class.new(value: value * other.to_f) end |
#+(other) ⇒ Hue
Returns New hue.
211 212 213 |
# File 'lib/unmagic/color.rb', line 211 def +(other) self.class.new(value: value + other.to_f) end |
#-(other) ⇒ Hue
Returns New hue.
217 218 219 |
# File 'lib/unmagic/color.rb', line 217 def -(other) self.class.new(value: value - other.to_f) end |
#/(other) ⇒ Hue
Returns New hue.
205 206 207 |
# File 'lib/unmagic/color.rb', line 205 def /(other) self.class.new(value: value / other.to_f) end |
#<=>(other) ⇒ Integer?
Returns Comparison result.
190 191 192 193 194 195 |
# File 'lib/unmagic/color.rb', line 190 def <=>(other) case other when Hue, Numeric value <=> other.to_f end end |
#abs ⇒ Hue
Returns Absolute value.
222 223 224 |
# File 'lib/unmagic/color.rb', line 222 def abs self.class.new(value: value.abs) end |
#degrees ⇒ Object
186 |
# File 'lib/unmagic/color.rb', line 186 def degrees = value |
#to_f ⇒ Object
185 |
# File 'lib/unmagic/color.rb', line 185 def to_f = value |