sybren-marechal-thermostat-exercise 0.4.0
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/thermostat +0 -0
- data/lib/Convert.rb +24 -0
- data/lib/JsonParser.rb +17 -0
- data/lib/TemperatureParser.rb +17 -0
- data/lib/Thermostaat.rb +18 -0
- data/lib/converters/FahrenheidToCelcius.rb +6 -0
- data/lib/converters/KelvinToCelcius.rb +6 -0
- data/lib/led_output.rb +5 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91f29370600ee33877bae8b9e535eb90f5d82633
|
4
|
+
data.tar.gz: 03722d796ba56ef326118cc4e3365bd1f31a49e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2076d62f17502cab9b69b34819cccdf1edb4f623bb663dd3df79b4d0d13091e4424b1ee18e501d0553deab16f0f66c81f8c102028618a4535825aff0315acea2
|
7
|
+
data.tar.gz: cd2d2f61f5f3bcea92d73e5a6dffd981e6839946000860215e6011cae32fb7565469464c2e5f91b4b2b2390d981b6275bd5c46f3cc9febdf16b8af8c2e9fdee0
|
data/bin/thermostat
ADDED
File without changes
|
data/lib/Convert.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class Converter
|
2
|
+
|
3
|
+
attr_accessor :value
|
4
|
+
attr_reader :temperatureInCelcius
|
5
|
+
|
6
|
+
def initialize(value, temperatureInCelcius)
|
7
|
+
@value = value
|
8
|
+
@temperatureInCelcius = temperatureInCelcius
|
9
|
+
end
|
10
|
+
|
11
|
+
def unit= (unit)
|
12
|
+
case unit
|
13
|
+
when "C"
|
14
|
+
@temperatureInCelcius = value
|
15
|
+
when "F"
|
16
|
+
@temperatureInCelcius = FahrenheidToCelcius.convert(value)
|
17
|
+
when "K"
|
18
|
+
@temperatureInCelcius = KelvinToCelcius.convert(value)
|
19
|
+
else
|
20
|
+
@temperatureInCelcius = "not a correct value"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/JsonParser.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class JsonParser
|
2
|
+
|
3
|
+
def getCirculation(thermostat)
|
4
|
+
|
5
|
+
heating_on = {"heating":"on", "airo":"off"}
|
6
|
+
airco_on = {"heating":"off", "airco":"on"}
|
7
|
+
|
8
|
+
if thermostat.cooling? == true
|
9
|
+
circulation = JSON.pretty_generate(airco_on)
|
10
|
+
elsif thermostat.heating? == true
|
11
|
+
circulation = JSON.pretty_generate(heating_on)
|
12
|
+
else
|
13
|
+
circulation = "nothing to do"
|
14
|
+
end
|
15
|
+
return circulation
|
16
|
+
end
|
17
|
+
end
|
data/lib/Thermostaat.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Thermostat
|
2
|
+
|
3
|
+
attr_accessor :actual_temperature, :wanted_temperature
|
4
|
+
|
5
|
+
def initialize(wanted_temperature, actual_temperature, range_temperature)
|
6
|
+
@wanted_temperature = wanted_temperature
|
7
|
+
@actual_temperature = actual_temperature
|
8
|
+
@range_temperature = range_temperature
|
9
|
+
end
|
10
|
+
|
11
|
+
def heating?
|
12
|
+
@wanted_temperature > @actual_temperature + @range_temperature
|
13
|
+
end
|
14
|
+
|
15
|
+
def cooling?
|
16
|
+
@wanted_temperature < @actual_temperature - @range_temperature
|
17
|
+
end
|
18
|
+
end
|
data/lib/led_output.rb
ADDED
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sybren-marechal-thermostat-exercise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sybren marechal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: ": Write a longer description or delete this line."
|
42
|
+
email:
|
43
|
+
- sybrenmarechal@icloud.com
|
44
|
+
executables:
|
45
|
+
- thermostat
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- "./lib/Convert.rb"
|
50
|
+
- "./lib/JsonParser.rb"
|
51
|
+
- "./lib/TemperatureParser.rb"
|
52
|
+
- "./lib/Thermostaat.rb"
|
53
|
+
- "./lib/converters/FahrenheidToCelcius.rb"
|
54
|
+
- "./lib/converters/KelvinToCelcius.rb"
|
55
|
+
- "./lib/led_output.rb"
|
56
|
+
- bin/thermostat
|
57
|
+
homepage: https://github.com/svl-softwareengineering-2018/thermostat-sybren-marechal
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.5.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: This is a thermostat project
|
81
|
+
test_files: []
|