bridge 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
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.15"
8
+ s.version = "0.0.16"
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-02}
12
+ s.date = %q{2010-03-03}
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 = [
@@ -44,13 +44,13 @@ Gem::Specification.new do |s|
44
44
  s.rubygems_version = %q{1.3.6}
45
45
  s.summary = %q{Contract bridge utilities}
46
46
  s.test_files = [
47
- "test/helper.rb",
48
- "test/test_bid.rb",
49
- "test/test_card.rb",
47
+ "test/test_bridge.rb",
50
48
  "test/test_trick.rb",
51
49
  "test/test_deal.rb",
52
- "test/test_bridge.rb",
53
- "test/test_score.rb"
50
+ "test/helper.rb",
51
+ "test/test_score.rb",
52
+ "test/test_bid.rb",
53
+ "test/test_card.rb"
54
54
  ]
55
55
 
56
56
  if s.respond_to? :specification_version then
data/lib/bridge.rb CHANGED
@@ -116,4 +116,15 @@ module Bridge
116
116
  def self.no_trump?(string)
117
117
  NO_TRUMP == string
118
118
  end
119
+
120
+ def self.partner_of(direction)
121
+ return unless DIRECTIONS.include?(direction)
122
+ i = (DIRECTIONS.index(direction) + 2) % 4
123
+ DIRECTIONS[i]
124
+ end
125
+
126
+ def self.side_of(direction)
127
+ return unless DIRECTIONS.include?(direction)
128
+ [direction, partner_of(direction)].sort.join
129
+ end
119
130
  end
data/test/test_bridge.rb CHANGED
@@ -8,4 +8,18 @@ class TestBridge < Test::Unit::TestCase
8
8
  test "number of possible bridge deals is not valid deal id" do
9
9
  assert_false Bridge.deal_id?(Bridge::DEALS)
10
10
  end
11
+
12
+ test "return partner of direction" do
13
+ assert_equal "N", Bridge.partner_of("S")
14
+ assert_equal "S", Bridge.partner_of("N")
15
+ assert_equal "E", Bridge.partner_of("W")
16
+ assert_equal "W", Bridge.partner_of("E")
17
+ end
18
+
19
+ test "return side of direction" do
20
+ assert_equal "NS", Bridge.side_of("S")
21
+ assert_equal "NS", Bridge.side_of("N")
22
+ assert_equal "EW", Bridge.side_of("W")
23
+ assert_equal "EW", Bridge.side_of("E")
24
+ end
11
25
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 15
9
- version: 0.0.15
8
+ - 16
9
+ version: 0.0.16
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-02 00:00:00 +01:00
17
+ date: 2010-03-03 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -90,10 +90,10 @@ signing_key:
90
90
  specification_version: 3
91
91
  summary: Contract bridge utilities
92
92
  test_files:
93
- - test/helper.rb
94
- - test/test_bid.rb
95
- - test/test_card.rb
93
+ - test/test_bridge.rb
96
94
  - test/test_trick.rb
97
95
  - test/test_deal.rb
98
- - test/test_bridge.rb
96
+ - test/helper.rb
99
97
  - test/test_score.rb
98
+ - test/test_bid.rb
99
+ - test/test_card.rb