class TemperatureConverter
Public Class Methods
new(temp)
click to toggle source
# File lib/temperature_converter.rb, line 5 def initialize temp @temp = temp.to_f end
Public Instance Methods
convert_to_celcius()
click to toggle source
# File lib/temperature_converter.rb, line 19 def convert_to_celcius (@temp).to_s + "°C" end
convert_to_fahrenheit()
click to toggle source
# File lib/temperature_converter.rb, line 11 def convert_to_fahrenheit ((@temp * 1.8)+32).to_s + "°F" end
convert_to_kelvin()
click to toggle source
# File lib/temperature_converter.rb, line 15 def convert_to_kelvin (@temp + 273.15).to_s + "°K" end
from_file_temp_celcius()
click to toggle source
# File lib/temperature_converter.rb, line 31 def from_file_temp_celcius @temp=File.read("./data/temp.txt").to_s + " °C" end
from_file_temp_fahrenheit()
click to toggle source
# File lib/temperature_converter.rb, line 23 def from_file_temp_fahrenheit @temp=((File.read("./data/temp.txt").to_f*1.8)+32).to_s + " °F" end
from_file_temp_kelvin()
click to toggle source
# File lib/temperature_converter.rb, line 27 def from_file_temp_kelvin @temp=(File.read("./data/temp.txt").to_f+273.15).to_s + " °K" end
from_url_temp_celcius()
click to toggle source
# File lib/temperature_converter.rb, line 43 def from_url_temp_celcius @temp=(open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }) + " °C" end
from_url_temp_fahrenheit()
click to toggle source
# File lib/temperature_converter.rb, line 35 def from_url_temp_fahrenheit @temp=(((open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }).to_f*1.8)+32).to_s + " °F" end
from_url_temp_kelvin()
click to toggle source
# File lib/temperature_converter.rb, line 39 def from_url_temp_kelvin @temp=((open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }).to_f+273.15).to_s + " °K" end