bridge 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bridge.gemspec +2 -2
- data/lib/bridge.rb +19 -2
- data/test/test_bridge.rb +16 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.20
|
data/bridge.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bridge}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.20"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Kuźma"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-18}
|
13
13
|
s.description = %q{Useful contract bridge utilities - deal generator, id to deal and deal to id conversion}
|
14
14
|
s.email = %q{qoobaa+github@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/bridge.rb
CHANGED
@@ -118,13 +118,30 @@ module Bridge
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def self.partner_of(direction)
|
121
|
-
return unless
|
121
|
+
return unless direction?(direction)
|
122
122
|
i = (DIRECTIONS.index(direction) + 2) % 4
|
123
123
|
DIRECTIONS[i]
|
124
124
|
end
|
125
125
|
|
126
126
|
def self.side_of(direction)
|
127
|
-
return unless
|
127
|
+
return unless direction?(direction)
|
128
128
|
[direction, partner_of(direction)].sort.join
|
129
129
|
end
|
130
|
+
|
131
|
+
def self.next_direction(direction)
|
132
|
+
return DIRECTIONS.first if direction.nil?
|
133
|
+
return unless direction?(direction)
|
134
|
+
next_for_collection(DIRECTIONS, direction)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.next_vulnerable(vulnerable)
|
138
|
+
return VULNERABILITIES.first if vulnerable.nil?
|
139
|
+
return unless VULNERABILITIES.include?(vulnerable)
|
140
|
+
next_for_collection(VULNERABILITIES, vulnerable)
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.next_for_collection(collection, current)
|
144
|
+
i = (collection.index(current) + 1) % collection.size
|
145
|
+
collection[i]
|
146
|
+
end
|
130
147
|
end
|
data/test/test_bridge.rb
CHANGED
@@ -22,4 +22,20 @@ class TestBridge < Test::Unit::TestCase
|
|
22
22
|
assert_equal "EW", Bridge.side_of("W")
|
23
23
|
assert_equal "EW", Bridge.side_of("E")
|
24
24
|
end
|
25
|
+
|
26
|
+
test "return next direction" do
|
27
|
+
assert_equal "E", Bridge.next_direction("N")
|
28
|
+
assert_equal "S", Bridge.next_direction("E")
|
29
|
+
assert_equal "W", Bridge.next_direction("S")
|
30
|
+
assert_equal "N", Bridge.next_direction("W")
|
31
|
+
assert_equal "N", Bridge.next_direction(nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
test "return next vulnerable" do
|
35
|
+
assert_equal "NONE", Bridge.next_vulnerable("BOTH")
|
36
|
+
assert_equal "NS", Bridge.next_vulnerable("NONE")
|
37
|
+
assert_equal "EW", Bridge.next_vulnerable("NS")
|
38
|
+
assert_equal "BOTH", Bridge.next_vulnerable("EW")
|
39
|
+
assert_equal "BOTH", Bridge.next_vulnerable(nil)
|
40
|
+
end
|
25
41
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 20
|
9
|
+
version: 0.0.20
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Jakub Ku\xC5\xBAma"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-18 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|