Module: TemperatureConversion
- Included in:
- UnitConversion
- Defined in:
- lib/unit_conversion/temperature_conversion.rb
Instance Method Summary collapse
- #to_celcius ⇒ Object
- #to_fahrenheit ⇒ Object
-
#to_kelvin ⇒ Object
Proxy = Kelvin.
- #to_rankine ⇒ Object
Instance Method Details
#to_celcius ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/unit_conversion/temperature_conversion.rb', line 14 def to_celcius if @unit == 'kelvin' @measurement -= 273.15 else self.to_kelvin @unit = 'kelvin' self.to_celcius end end |
#to_fahrenheit ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/unit_conversion/temperature_conversion.rb', line 24 def to_fahrenheit if @unit == 'kelvin' @measurement = (@measurement * 9 / 5.0) - 459.67 else self.to_kelvin @unit = 'kelvin' self.to_fahrenheit end end |
#to_kelvin ⇒ Object
Proxy = Kelvin
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/unit_conversion/temperature_conversion.rb', line 3 def to_kelvin case @unit when 'celcius' @measurement += 273.15 when 'rankine' @measurement /= 1.8 when 'fahrenheit' @measurement = (@measurement + 459.67) * 5 / 9 end end |
#to_rankine ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/unit_conversion/temperature_conversion.rb', line 34 def to_rankine if @unit == 'kelvin' @measurement *= 1.8 else self.to_kelvin @unit = 'kelvin' self.to_rankine end end |