Permalink
Browse files

Implement cards for flush

  • Loading branch information...
camillebaldock committed Sep 8, 2014
1 parent ada5838 commit d90e840ddb1bc1e9e3b02da15a5173a27198fb19
Showing with 10 additions and 2 deletions.
  1. +7 −2 lib/hand.rb
  2. +3 −0 spec/hand_spec.rb
View
@@ -38,7 +38,7 @@ def rank
elsif full_house
{ :type => :full_house }
elsif flush
{ :type => :flush }
flush
elsif straight
straight
elsif has_three
@@ -111,7 +111,12 @@ def full_house
end
def flush
suits_per_occurence[5]
if suits_per_occurence[5]
{
:type => :flush,
:cards => cards.map(&:pips).sort.reverse
}
end
end
def straight
View
@@ -82,6 +82,9 @@
it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :flush
end
it "returns the other cards correctly" do
expect(hand.rank.fetch(:cards)).to eq [10,8,7,6,5]
end
end
context "straight hand" do

0 comments on commit d90e840

Please sign in to comment.