class Temperature

Temperature type with unit convertion methods

The Temperature class accepts any temperature value in degrees celsius and can convert it to any other unit with helper methods @author Sille Van Landschoot <info@sillevl.be>

Constants

FAHRENHEIT_OFFSET
FAHRENHEIT_SLOPE
KELVIN_SHIFT

Attributes

temperature[R]

Public Class Methods

new(temperature) click to toggle source

@param temperature [Number] temperature value in degrees celsius

# File lib/temperature.rb, line 16
def initialize temperature
    @temperature = temperature
end

Public Instance Methods

to_celsius() click to toggle source

Return the temperature value in degrees celsius @return [Number] temperature in degrees celsius @example

temperature = Temperature.new 12.3
puts temperature.to_celsius
# File lib/temperature.rb, line 25
def to_celsius
    temperature
end
to_fahrenheit() click to toggle source
# File lib/temperature.rb, line 29
def to_fahrenheit
    (to_celsius * FAHRENHEIT_SLOPE) + FAHRENHEIT_OFFSET
end
to_kelvin() click to toggle source
# File lib/temperature.rb, line 33
def to_kelvin
    to_celsius + KELVIN_SHIFT
end