Skip to content

Commit

Permalink
Extract code that should be de-duped
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebaldock committed Sep 3, 2014
1 parent 7044d07 commit 2159bec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/hand.rb
Expand Up @@ -39,15 +39,17 @@ def rank


##bob ##bob
def pip_count def pip_count
grouped_cards = cards.map(&:pips).group_by { |i| i } pips = cards.map(&:pips)
grouped_cards = pips.group_by { |i| i }
grouped_cards.each do |key, value| grouped_cards.each do |key, value|
grouped_cards[key] = value.count grouped_cards[key] = value.count
end end
end end


##DUPE! pip_count ##DUPE! pip_count
def suit_count def suit_count
grouped_cards = cards.map(&:suit).group_by { |i| i } suits = cards.map(&:suit)
grouped_cards = suits.group_by { |i| i }
grouped_cards.each do |key, value| grouped_cards.each do |key, value|
grouped_cards[key] = value.count grouped_cards[key] = value.count
end end
Expand Down

0 comments on commit 2159bec

Please sign in to comment.