thermostat_Daan_Ver_Eecke 0.4.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/converter.rb +15 -0
- data/lib/logger.rb +18 -0
- data/lib/rgb.rb +15 -0
- data/lib/thermostat.rb +18 -0
- data/lib/thermostat_Daan_Ver_Eecke.rb +27 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56bf41ae0fb52d2ba0992b41c4d3277701c6c07e
|
4
|
+
data.tar.gz: ebac5b116109b70f332d1bc5ccf23008623f861b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7fc38f21713ef0679273e7872f98d2fbe1442925adacb9a305c4c8a759b62da8f1e93ca7a9e6487914b98e1c94685fb478c6b6234afe823fbeb8b8a232a6caa7
|
7
|
+
data.tar.gz: 163870740697b324b6c08228193ad60c6de5281a5dbd772420b470ad6fa284bcef0eb306179ad5300331ccb2e887c10c1e448b79a2f70ec27dfde36e391a728a
|
data/lib/converter.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Converter
|
2
|
+
|
3
|
+
public
|
4
|
+
attr_reader :celsius_value
|
5
|
+
|
6
|
+
def convert(temperature, unit = "C")
|
7
|
+
if unit == "F"
|
8
|
+
@celsius_value = ((temperature -32)/1.8)
|
9
|
+
elsif unit == "K"
|
10
|
+
@celsius_value = (temperature - 273.15)
|
11
|
+
else
|
12
|
+
@celsius_value = temperature
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/logger.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Logger
|
2
|
+
|
3
|
+
def print_heating(heating)
|
4
|
+
"The heating is : #{heating}."
|
5
|
+
end
|
6
|
+
|
7
|
+
def print_airco(airco)
|
8
|
+
"The airco is : #{airco}."
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_led_state(led)
|
12
|
+
"The led is : #{led}."
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_json(heating,airco,led)
|
16
|
+
"{\"heating\" : \"#{heating}\", \"airco\" : \"#{airco}\", \"led\" : \"#{led}\"}"
|
17
|
+
end
|
18
|
+
end
|
data/lib/rgb.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Rgb
|
2
|
+
|
3
|
+
public
|
4
|
+
attr_reader :state
|
5
|
+
|
6
|
+
def color(current_temperature, wanted_temperature, range)
|
7
|
+
if (current_temperature < (wanted_temperature - range))
|
8
|
+
@state = "red"
|
9
|
+
elsif (current_temperature > (wanted_temperature + range))
|
10
|
+
@state = "blue"
|
11
|
+
else
|
12
|
+
@state = "green"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/thermostat.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Thermostat
|
2
|
+
|
3
|
+
public
|
4
|
+
attr_reader :airco, :heating
|
5
|
+
|
6
|
+
def regulate(current_temperature, wanted_temperature, range = 0.5)
|
7
|
+
if (current_temperature < (wanted_temperature - range))
|
8
|
+
@heating = "on"
|
9
|
+
@airco = "off"
|
10
|
+
elsif (current_temperature > (wanted_temperature + range))
|
11
|
+
@heating = "off"
|
12
|
+
@airco = "on"
|
13
|
+
else
|
14
|
+
@heating = "off"
|
15
|
+
@airco = "off"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'converter.rb'
|
2
|
+
require_relative 'thermostat.rb'
|
3
|
+
require_relative 'rgb.rb'
|
4
|
+
require_relative 'logger.rb'
|
5
|
+
|
6
|
+
conversion = Converter.new
|
7
|
+
honeywell = Thermostat.new
|
8
|
+
led = Rgb.new
|
9
|
+
logger = Logger.new
|
10
|
+
|
11
|
+
wanted_temperature = ARGV[0].to_i
|
12
|
+
current_temperature = ARGV[1].to_i
|
13
|
+
range = ARGV[2].to_f
|
14
|
+
unit = ARGV[3]
|
15
|
+
|
16
|
+
conversion.convert(wanted_temperature,unit)
|
17
|
+
converted_temperature = conversion.celsius_value
|
18
|
+
|
19
|
+
puts converted_temperature
|
20
|
+
|
21
|
+
honeywell.regulate(current_temperature,converted_temperature,range)
|
22
|
+
led.color(current_temperature,converted_temperature,range)
|
23
|
+
|
24
|
+
puts logger.print_heating(honeywell.heating)
|
25
|
+
puts logger.print_airco(honeywell.airco)
|
26
|
+
puts logger.print_led_state(led.state)
|
27
|
+
puts logger.get_json(honeywell.heating,honeywell.airco,led.state)
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thermostat_Daan_Ver_Eecke
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daan Ver Eecke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2010-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple thermostat gem
|
14
|
+
email: ''
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/converter.rb
|
20
|
+
- lib/logger.rb
|
21
|
+
- lib/rgb.rb
|
22
|
+
- lib/thermostat.rb
|
23
|
+
- lib/thermostat_Daan_Ver_Eecke.rb
|
24
|
+
homepage: http://rubygems.org/gems/thermostat_Daan_Ver_Eecke
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.3.1
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.5.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: thermostat
|
48
|
+
test_files: []
|