Project
tempture-convertor
# Temperature Convertor
convert temperature from fehrenheit or kelvin to celsius
## Detail
The "Temperature" class stores and controls the value and convert function
**Constructor**
> ` def initialize(temperature, mode) `
The initialization process retrieve temperature user input and specific Temperature Mode and store temperature in celsius form.<br>
[param] temperature: float --> the temperature value<br>
[param] mode: TemperatureMode --> the temperature unit (Fahrenheit, Celsius or Kelvin)<br>
Note the TemperatureMode is an enumerate that holds value of TemperatureMode::Celsius, TemperatureMode::Fahrenheit or TemperatureMode::Kelvin. The implementation is:<br>
```ruby
module TemperatureMode
Celsius = 1
Fahrenheit = 2
Kelvin = 4
end
```
**method**
> ` def toFahrenheit() `
Convert the temperature to Fahrenheit<br>
[return] temperature in Fahrenheit, type in float<br>
> ` def toKelvin() `
Convert the temperature to Kelvin<br>
[return] temperature in Kelvin, type in float<br>
**Property**
> ` this.temperature `
temperature in Celsius, type in float
## Get Start
Use following script for testing
```ruby
temp = Temperature.new(-24, 1)
puts temp.toString
puts "Current temperature is #{'%.2f' % temp.toFahrenheit} °F"
puts "Current temperature is #{'%.2f' % temp.toKelvin} K"
```
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
Development
Licenses
GPL-3.0-only
Dependencies