Class: Temperature
- Inherits:
-
Object
- Object
- Temperature
- Defined in:
- lib/temperature.rb
Constant Summary collapse
- KELVIN =
273.15
- FAHRENHEIT_OFFSET =
32
- FAHRENHEIT_SLOPE =
Rational(9,5)
Instance Attribute Summary collapse
-
#temperature ⇒ Object
readonly
Returns the value of attribute temperature.
Instance Method Summary collapse
Instance Attribute Details
#temperature ⇒ Object (readonly)
Returns the value of attribute temperature.
7 8 9 |
# File 'lib/temperature.rb', line 7 def temperature @temperature end |
Instance Method Details
#celsius ⇒ Object
9 10 11 |
# File 'lib/temperature.rb', line 9 def celsius $temperature.to_f end |
#to_fahrenheit ⇒ Object
13 14 15 |
# File 'lib/temperature.rb', line 13 def to_fahrenheit ($temperature.to_f * FAHRENHEIT_SLOPE) + FAHRENHEIT_OFFSET end |
#to_kelvin ⇒ Object
17 18 19 |
# File 'lib/temperature.rb', line 17 def to_kelvin $temperature.to_f + KELVIN end |