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 CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('traffic_light', '0.2.0') do |p|
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"
@@ -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
- @message = @sp.read.chomp
40
+ if blind?
41
+ @message = ""
42
+ else
43
+ @message = @sp.read.chomp
44
+ end
32
45
  end
33
46
 
34
47
  def setColors(colors)
@@ -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!
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "traffic_light"
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nicolas Ledez"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traffic_light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: