Class: TemperatureConverter
- Inherits:
-
Object
- Object
- TemperatureConverter
- Defined in:
- lib/temperature_converter.rb
Class Method Summary collapse
- .commandlinetemp(input, printer_type) ⇒ Object
- .filetemp(path, printer_type) ⇒ Object
-
.keuzePrinter(printer_type, temperature) ⇒ Object
Converting and outputting in correct way.
- .mqtttemp(host, port, username, password, printer_type) ⇒ Object
- .urltemp(url, printer_type) ⇒ Object
Class Method Details
.commandlinetemp(input, printer_type) ⇒ Object
12 13 14 15 16 |
# File 'lib/temperature_converter.rb', line 12 def self.commandlinetemp(input, printer_type) temperature = CommandlineReader.reader(input) puts "Temperatuur uit commandline:" keuzePrinter(printer_type, temperature) end |
.filetemp(path, printer_type) ⇒ Object
18 19 20 21 22 |
# File 'lib/temperature_converter.rb', line 18 def self.filetemp(path,printer_type) temperature = FileReader.file_open(path) puts "Temperatuur uit file:" keuzePrinter(printer_type, temperature) end |
.keuzePrinter(printer_type, temperature) ⇒ Object
Converting and outputting in correct way
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/temperature_converter.rb', line 37 def self.keuzePrinter(printer_type, temperature) celc = Converter.to_celcius(temperature) fahr = Converter.to_fahrenheit(temperature) kelv = Converter.to_kelvin(temperature) case printer_type when "text" TextPrinter.printer(celc, fahr, kelv) when "json" JsonPrinter.printer(celc, fahr, kelv) when "html" HtmlPrinter.printer(celc, fahr, kelv) else puts "What the hell is #{printer_type}" end end |
.mqtttemp(host, port, username, password, printer_type) ⇒ Object
30 31 32 33 34 |
# File 'lib/temperature_converter.rb', line 30 def self.mqtttemp(host, port, username, password, printer_type) temperature = MqttReader.mqtt_open(host, port, username, password) puts "Temperatuur uit MQTT:" keuzePrinter(printer_type, temperature) end |