Permalink
Browse files

Implement highest and full_of for full house

  • Loading branch information...
camillebaldock committed Sep 8, 2014
1 parent d90e840 commit 8206f584749e446d2a62a3411c3341d11091fafe
Showing with 14 additions and 2 deletions.
  1. +8 −2 lib/hand.rb
  2. +6 −0 spec/hand_spec.rb
View
@@ -36,7 +36,7 @@ def rank
elsif has_four
has_four
elsif full_house
- { :type => :full_house }
+ full_house
elsif flush
flush
elsif straight
@@ -107,7 +107,13 @@ def has_two
end
def full_house
- pips_per_occurence[3] && pips_per_occurence[2]
+ if pips_per_occurence[3] && pips_per_occurence[2]
+ {
+ :type => :full_house,
+ :highest => pips_per_occurence[3].first,
+ :full_of => pips_per_occurence[2].first
+ }
+ end
end
def flush
View
@@ -75,6 +75,12 @@
it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :full_house
end
+ it "returns the highest correctly" do
+ expect(hand.rank.fetch(:highest)).to eq 5
+ end
+ it "returns the full_of value correctly" do
+ expect(hand.rank.fetch(:full_of)).to eq 6
+ end
end
context "flush hand" do

0 comments on commit 8206f58

Please sign in to comment.