Class: Temperature
- Inherits:
-
Object
- Object
- Temperature
- Defined in:
- lib/temperature.rb
Instance Method Summary collapse
Instance Method Details
#convert(temp, unit) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/temperature.rb', line 2 def convert(temp, unit) if(unit == "C") @temp = temp elsif(unit == "K") # normally it need to be '273.15', but if we do this the led will never # be "green" @temp = temp - 273 elsif(unit == "F") @temp = ((temp - 32) * 5 / 9) else @temp = temp end end |