Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/gd2-ffij.rb
Instance Method Summary collapse
-
#degrees ⇒ Object
(also: #degree)
Express an angle in degrees, e.g.
-
#percent ⇒ Object
Express a percentage, e.g.
-
#to_degrees ⇒ Object
Convert an angle (in radians) to degrees.
-
#to_percent ⇒ Object
Convert a number to a percentage value, e.g.
Instance Method Details
#degrees ⇒ Object Also known as: degree
Express an angle in degrees, e.g. 90.degrees. Angles are converted to radians.
188 189 190 |
# File 'lib/gd2-ffij.rb', line 188 def degrees self * 2 * Math::PI / 360 end |
#percent ⇒ Object
Express a percentage, e.g. 50.percent. Percentages are floating point values, e.g. 0.5.
204 205 206 |
# File 'lib/gd2-ffij.rb', line 204 def percent self / 100.0 end |
#to_degrees ⇒ Object
Convert an angle (in radians) to degrees.
196 197 198 |
# File 'lib/gd2-ffij.rb', line 196 def to_degrees self * 360 / Math::PI / 2 end |
#to_percent ⇒ Object
Convert a number to a percentage value, e.g. 0.5 to 50.0.
211 212 213 |
# File 'lib/gd2-ffij.rb', line 211 def to_percent self * 100 end |