module TemperatureConversion
Public Instance Methods
to_celcius()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
Proxy = Kelvin
# 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()
click to toggle source
# 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