traffic_light 0.2.0 → 0.3.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.
- data/Rakefile +1 -1
- data/lib/traffic_light.rb +14 -1
- data/spec/traffic_light_spec.rb +12 -0
- data/traffic_light.gemspec +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('traffic_light', '0.
|
5
|
+
Echoe.new('traffic_light', '0.3.0') do |p|
|
6
6
|
p.description = "Drive a traffic light with an Arduino."
|
7
7
|
p.url = "http://github.com/nledez/traffic_light"
|
8
8
|
p.author = "Nicolas Ledez"
|
data/lib/traffic_light.rb
CHANGED
@@ -14,6 +14,7 @@ class TrafficLight
|
|
14
14
|
@sp.read_timeout = 1000
|
15
15
|
|
16
16
|
@opened = true
|
17
|
+
@blind = false
|
17
18
|
|
18
19
|
clear
|
19
20
|
end
|
@@ -22,13 +23,25 @@ class TrafficLight
|
|
22
23
|
@opened
|
23
24
|
end
|
24
25
|
|
26
|
+
def blind=(value)
|
27
|
+
@blind = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def blind?
|
31
|
+
@blind
|
32
|
+
end
|
33
|
+
|
25
34
|
def close!
|
26
35
|
@sp.close
|
27
36
|
@opened = false
|
28
37
|
end
|
29
38
|
|
30
39
|
def read
|
31
|
-
|
40
|
+
if blind?
|
41
|
+
@message = ""
|
42
|
+
else
|
43
|
+
@message = @sp.read.chomp
|
44
|
+
end
|
32
45
|
end
|
33
46
|
|
34
47
|
def setColors(colors)
|
data/spec/traffic_light_spec.rb
CHANGED
@@ -45,6 +45,18 @@ describe "Can change light colors" do
|
|
45
45
|
@traffic.message.should == "7 -> GOR"
|
46
46
|
end
|
47
47
|
|
48
|
+
it "Can configure blind mode" do
|
49
|
+
@traffic.blind?.should == false
|
50
|
+
@traffic.blind = true
|
51
|
+
@traffic.blind?.should == true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Can be blind" do
|
55
|
+
@traffic.blind = true
|
56
|
+
@traffic.all
|
57
|
+
@traffic.message.should == ""
|
58
|
+
end
|
59
|
+
|
48
60
|
it "Close socket" do
|
49
61
|
@traffic.open? == true
|
50
62
|
@traffic.close!
|
data/traffic_light.gemspec
CHANGED