stefanrottierstemperatureconverter 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/temp-conver +53 -0
- data/lib/Converter.rb +0 -0
- data/lib/Printer.rb +0 -0
- data/lib/Reader_server.rb +0 -0
- data/lib/Reader_url.rb +0 -0
- data/lib/gemtest.rb +7 -0
- data/lib/temperature_converter.rb +48 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 84bd5745a0d280bf5cb4144396123bf66fe78b85
|
|
4
|
+
data.tar.gz: ba50c6ed5d6f6784d7862902a890e49101dbb110
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b418317c3060a5e13613a66b241b4c7ea85db1e99aade9631e2582de24152f69212657755a158a2ae5ad3da464c677de64439698777fe22fbb73b5e3eb0b2b91
|
|
7
|
+
data.tar.gz: 50367bfcb6af4930a435779fc6638e771903c9a20d6c81b1f4acbee48932b657d120178377f66eb15b379bce01046716b426e81e572e9983f4281ce20e3a6dc1
|
data/bin/temp-conver
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'temperature_converter.rb'
|
|
4
|
+
require "open-uri"
|
|
5
|
+
require 'rubygems'
|
|
6
|
+
require 'mqtt'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
input = ARGV.first.to_f
|
|
11
|
+
|
|
12
|
+
temperature_converter = TemperatureConverter.new input
|
|
13
|
+
|
|
14
|
+
puts "Converted values from commandline"
|
|
15
|
+
puts temperature_converter.convert_to_fahrenheit
|
|
16
|
+
puts temperature_converter.convert_to_kelvin
|
|
17
|
+
puts temperature_converter.convert_to_celcius + "\r\n\n"
|
|
18
|
+
puts "{celsius: " +temperature_converter.convert_to_celcius + ", fahrenheit: " +temperature_converter.convert_to_fahrenheit + ", kelvin: " + temperature_converter.convert_to_kelvin + "}\r\n\n"
|
|
19
|
+
puts "<div>Celcius: " + temperature_converter.convert_to_celcius + " </div> "
|
|
20
|
+
puts "<div>Fahrenheit: " + temperature_converter.convert_to_fahrenheit + " </div> "
|
|
21
|
+
puts "<div>Kelvin: " + temperature_converter.convert_to_kelvin + " </div>\r\n\n "
|
|
22
|
+
|
|
23
|
+
puts "Values from txt file"
|
|
24
|
+
puts temperature_converter.from_file_temp_fahrenheit
|
|
25
|
+
puts temperature_converter.from_file_temp_kelvin
|
|
26
|
+
puts temperature_converter.from_file_temp_celcius + "\r\n\n"
|
|
27
|
+
puts "{celsius: " +temperature_converter.from_file_temp_celcius + ", fahrenheit: " +temperature_converter.from_file_temp_fahrenheit + ", kelvin: " + temperature_converter.from_file_temp_kelvin + "}\r\n\n"
|
|
28
|
+
puts "<div>Celcius: " + temperature_converter.from_file_temp_celcius + " </div> "
|
|
29
|
+
puts "<div>Fahrenheit: " + temperature_converter.from_file_temp_fahrenheit + " </div> "
|
|
30
|
+
puts "<div>Kelvin: " + temperature_converter.from_file_temp_kelvin + " </div>\r\n\n "
|
|
31
|
+
|
|
32
|
+
puts "Values from url"
|
|
33
|
+
puts temperature_converter.from_url_temp_fahrenheit
|
|
34
|
+
puts temperature_converter.from_url_temp_kelvin
|
|
35
|
+
puts temperature_converter.from_url_temp_celcius + "\r\n\n"
|
|
36
|
+
puts "{celsius: " +temperature_converter.from_url_temp_celcius + ", fahrenheit: " +temperature_converter.from_url_temp_fahrenheit + ", kelvin: " + temperature_converter.from_url_temp_kelvin + "}\r\n\n"
|
|
37
|
+
puts "<div>Celcius: " + temperature_converter.from_url_temp_celcius + " </div> "
|
|
38
|
+
puts "<div>Fahrenheit: " + temperature_converter.from_url_temp_fahrenheit + " </div> "
|
|
39
|
+
puts "<div>Kelvin: " + temperature_converter.from_url_temp_kelvin + " </div>\r\n\n "
|
|
40
|
+
|
|
41
|
+
puts "Values from server"
|
|
42
|
+
client = MQTT::Client.connect(
|
|
43
|
+
:host => 'staging.thethingsnetwork.org',
|
|
44
|
+
:port => 1883,
|
|
45
|
+
:username =>'70B3D57ED00012B2',
|
|
46
|
+
:password =>'c8iuTSccnypK1eoFzEb/OoqB2FVAiFg/aEaYesnNf4w=',
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
#Get values from server
|
|
50
|
+
client.get('70B3D57ED00012B2/devices/00000000AE6C63E4/up') do |topic,message|
|
|
51
|
+
puts a = JSON.parse(message)['fields']['temperature']
|
|
52
|
+
#puts topic
|
|
53
|
+
end
|
data/lib/Converter.rb
ADDED
|
File without changes
|
data/lib/Printer.rb
ADDED
|
File without changes
|
|
File without changes
|
data/lib/Reader_url.rb
ADDED
|
File without changes
|
data/lib/gemtest.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class TemperatureConverter
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
def initialize temp
|
|
6
|
+
@temp = temp.to_f
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
public
|
|
10
|
+
|
|
11
|
+
def convert_to_fahrenheit
|
|
12
|
+
((@temp * 1.8)+32).to_s + "°F"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def convert_to_kelvin
|
|
16
|
+
(@temp + 273.15).to_s + "°K"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def convert_to_celcius
|
|
20
|
+
(@temp).to_s + "°C"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def from_file_temp_fahrenheit
|
|
24
|
+
@temp=((File.read("./data/temp.txt").to_f*1.8)+32).to_s + " °F"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def from_file_temp_kelvin
|
|
28
|
+
@temp=(File.read("./data/temp.txt").to_f+273.15).to_s + " °K"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def from_file_temp_celcius
|
|
32
|
+
@temp=File.read("./data/temp.txt").to_s + " °C"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def from_url_temp_fahrenheit
|
|
36
|
+
@temp=(((open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }).to_f*1.8)+32).to_s + " °F"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def from_url_temp_kelvin
|
|
40
|
+
@temp=((open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }).to_f+273.15).to_s + " °K"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def from_url_temp_celcius
|
|
44
|
+
@temp=(open('http://labict.be/software-engineering/temperature/api/temperature/fake') {|a| a.read }) + " °C"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: stefanrottierstemperatureconverter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Stefan Rottiers
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple temperature converter
|
|
14
|
+
email: stefan.rottiers@student.vives.be
|
|
15
|
+
executables:
|
|
16
|
+
- temp-conver
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/temp-conver
|
|
21
|
+
- lib/Converter.rb
|
|
22
|
+
- lib/Printer.rb
|
|
23
|
+
- lib/Reader_server.rb
|
|
24
|
+
- lib/Reader_url.rb
|
|
25
|
+
- lib/gemtest.rb
|
|
26
|
+
- lib/temperature_converter.rb
|
|
27
|
+
homepage: https://github.com/StefanRottiers
|
|
28
|
+
licenses:
|
|
29
|
+
- MIT
|
|
30
|
+
metadata: {}
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubyforge_project:
|
|
47
|
+
rubygems_version: 2.4.5.1
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: Temperature converter
|
|
51
|
+
test_files: []
|