class Convert
Convert
class will convert temperature in different units.
Public Instance Methods
convert(temperature, unit)
click to toggle source
Convert
method will loop over units and will check if unit is nil, celsius, kelvin or fahrenheit. It will convert the temperature in celsius, kelvin or fahrenheit @param [String] some wanted values:
* :unit [String] The unit of the temperature * :temperature [Double] The value of the temperature
@return [Double] the resulting temperature @example
convert.convert(86, 'fahrenheit') returns: 30
# File lib/convert.rb, line 16 def convert(temperature, unit) return temperature if unit.nil? return temperature if unit == 'celsius' return temperature - 273.15 if unit == 'kelvin' return (temperature - 32) / 1.8 if unit == 'fahrenheit' end