Class: TexasHoldem::Combinations::TwoPairs
- Inherits:
-
Combination
- Object
- Combination
- TexasHoldem::Combinations::TwoPairs
- Defined in:
- lib/texas-holdem/combinations/two_pairs.rb
Constant Summary
Constants inherited from Combination
Combination::MAX_COMBINATION_LENGTH
Instance Attribute Summary
Attributes inherited from Combination
#cards, #cards_by_rank, #cards_by_suit, #combination_cards, #kicker_cards
Instance Method Summary collapse
Methods inherited from Combination
#<=>, #has_combination?, #initialize, #to_s
Constructor Details
This class inherits a constructor from TexasHoldem::Combinations::Combination
Instance Method Details
#compare_same_rank(other) ⇒ Object
19 20 21 |
# File 'lib/texas-holdem/combinations/two_pairs.rb', line 19 def compare_same_rank(other) combination_cards.max <=> other.combination_cards.max end |
#get_combination_cards(cards) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/texas-holdem/combinations/two_pairs.rb', line 5 def get_combination_cards(cards) pairs = [] cards_by_rank.each do |rank, cards_of_same_rank| pairs << cards_of_same_rank if cards_of_same_rank.length == 2 end if pairs.length == 2 pairs.flatten elsif pairs.length > 2 pairs.sort_by { |pair| pair[0] }.last(2).flatten else [] end end |