rb-blink1 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/blink1/version.rb +1 -1
- data/lib/blink1.rb +29 -1
- metadata +2 -2
data/lib/blink1/version.rb
CHANGED
data/lib/blink1.rb
CHANGED
@@ -6,7 +6,21 @@ class Blink1
|
|
6
6
|
attr_accessor :millis
|
7
7
|
attr_accessor :delay_millis
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize option = nil
|
10
|
+
case option
|
11
|
+
when Fixnum
|
12
|
+
open_by_id(option)
|
13
|
+
when Hash
|
14
|
+
path = option[:path] || option["path"]
|
15
|
+
serial = option[:serial] || option["serial"]
|
16
|
+
if path
|
17
|
+
open_by_path(path)
|
18
|
+
elsif serial
|
19
|
+
open_by_serial(serial)
|
20
|
+
end
|
21
|
+
when String
|
22
|
+
open_by_serial(option)
|
23
|
+
end
|
10
24
|
@millis ||= 300
|
11
25
|
@delay_millis ||= 500
|
12
26
|
end
|
@@ -65,4 +79,18 @@ class Blink1
|
|
65
79
|
devs
|
66
80
|
end
|
67
81
|
|
82
|
+
def self.open option = nil, &block
|
83
|
+
b = self.new(option)
|
84
|
+
b.open if option.nil?
|
85
|
+
if block
|
86
|
+
begin
|
87
|
+
b.instance_eval &block
|
88
|
+
ensure
|
89
|
+
b.close
|
90
|
+
end
|
91
|
+
else
|
92
|
+
b
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
68
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-blink1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|