Class: Temperature

Inherits:
Object
  • Object
show all
Defined in:
lib/temperature.rb

Constant Summary collapse

KELVIN =
273.15
FAHRENHEIT_OFFSET =
32
FAHRENHEIT_SLOPE =
Rational(9,5)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temperatureObject (readonly)

Returns the value of attribute temperature.



7
8
9
# File 'lib/temperature.rb', line 7

def temperature
  @temperature
end

Instance Method Details

#celsiusObject



9
10
11
# File 'lib/temperature.rb', line 9

def celsius
	$temperature.to_f
end

#to_fahrenheitObject



13
14
15
# File 'lib/temperature.rb', line 13

def to_fahrenheit
 	($temperature.to_f * FAHRENHEIT_SLOPE) + FAHRENHEIT_OFFSET
end

#to_kelvinObject



17
18
19
# File 'lib/temperature.rb', line 17

def to_kelvin
	$temperature.to_f + KELVIN
end