bridge 0.0.8 → 0.0.9

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
data/bridge.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bridge}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
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"]
data/lib/bridge/bid.rb CHANGED
@@ -87,8 +87,4 @@ module Bridge
87
87
  bid.inspect
88
88
  end
89
89
  end
90
-
91
- def self.Bid(bid)
92
- Bid.new(bid)
93
- end
94
90
  end
data/lib/bridge/card.rb CHANGED
@@ -57,8 +57,4 @@ module Bridge
57
57
  card
58
58
  end
59
59
  end
60
-
61
- def self.Card(card)
62
- Card.new(card)
63
- end
64
60
  end
data/lib/bridge/deal.rb CHANGED
@@ -81,6 +81,11 @@ module Bridge
81
81
  id
82
82
  end
83
83
 
84
+ # Returns the direction that owns the card
85
+ def owner(card)
86
+ DIRECTIONS.find { |direction| self[direction].include?(card) }
87
+ end
88
+
84
89
  # Returns a random deal id
85
90
  def self.random_id
86
91
  rand(DEALS)
@@ -120,8 +125,4 @@ module Bridge
120
125
  instance_variable_set("@#{direction.to_s.downcase}", cards)
121
126
  end
122
127
  end
123
-
124
- def self.Deal(deal)
125
- Deal.new(deal)
126
- end
127
128
  end
data/test/test_deal.rb CHANGED
@@ -84,4 +84,20 @@ class TestDeal < Test::Unit::TestCase
84
84
  Bridge::Deal.from_id(-1)
85
85
  end
86
86
  end
87
+
88
+ test "owner returns correct direction" do
89
+ deal = Bridge::Deal.new({ "N" => ["SK", "S9", "S7", "S6", "S4", "S2", "HA", "HJ", "H2", "D7", "D2", "C6", "C3"],
90
+ "E" => ["SA", "SJ", "ST", "H3", "DA", "DK", "DT", "D9", "D8", "D5", "D4", "CK", "CJ"],
91
+ "S" => ["S8", "S5", "S3", "HK", "HQ", "HT", "H8", "H4", "DQ", "D3", "CQ", "C4", "C2"],
92
+ "W" => ["SQ", "H9", "H7", "H6", "H5", "DJ", "D6", "CA", "CT", "C9", "C8", "C7", "C5"] })
93
+
94
+ assert_equal "N", deal.owner("SK")
95
+ assert_equal "N", deal.owner("C3")
96
+ assert_equal "E", deal.owner("SJ")
97
+ assert_equal "E", deal.owner("CK")
98
+ assert_equal "S", deal.owner("S3")
99
+ assert_equal "S", deal.owner("CQ")
100
+ assert_equal "W", deal.owner("H6")
101
+ assert_equal "W", deal.owner("C9")
102
+ end
87
103
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Ku\xC5\xBAma"