Categories: None [Edit]
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.
[param] temperature: float --> the temperature value
[param] mode: TemperatureMode --> the temperature unit (Fahrenheit, Celsius or Kelvin)
Note the TemperatureMode is an enumerate that holds value of TemperatureMode::Celsius, TemperatureMode::Fahrenheit or TemperatureMode::Kelvin. The implementation is:
```ruby module TemperatureMode Celsius = 1 Fahrenheit = 2 Kelvin = 4 end ``` **method** > ` def toFahrenheit() ` Convert the temperature to Fahrenheit
[return] temperature in Fahrenheit, type in float
> ` def toKelvin() ` Convert the temperature to Kelvin
[return] temperature in Kelvin, type in float
**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" ```
[param] temperature: float --> the temperature value
[param] mode: TemperatureMode --> the temperature unit (Fahrenheit, Celsius or Kelvin)
Note the TemperatureMode is an enumerate that holds value of TemperatureMode::Celsius, TemperatureMode::Fahrenheit or TemperatureMode::Kelvin. The implementation is:
```ruby module TemperatureMode Celsius = 1 Fahrenheit = 2 Kelvin = 4 end ``` **method** > ` def toFahrenheit() ` Convert the temperature to Fahrenheit
[return] temperature in Fahrenheit, type in float
> ` def toKelvin() ` Convert the temperature to Kelvin
[return] temperature in Kelvin, type in float
**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" ```
Total
Ranking: 194,568 of 195,377
Downloads: 228
Daily
Ranking: 128,413 of 195,357
Downloads: 0
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|
Depends on
| Rank | Downloads | Name |
|---|
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | shirika |