Class: TexasHoldem::Combinations::Flush

Inherits:
Combination show all
Defined in:
lib/texas-holdem/combinations/flush.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



12
13
14
15
16
17
18
19
# File 'lib/texas-holdem/combinations/flush.rb', line 12

def compare_same_rank(other)
  combination_cards.each_with_index do |highest_card, i|
    other_highest_card = other.combination_cards[i]
    compared_by_high = highest_card <=> other_highest_card
    return compared_by_high unless compared_by_high == 0
  end
  0
end

#get_combination_cards(cards) ⇒ Object



5
6
7
8
9
10
# File 'lib/texas-holdem/combinations/flush.rb', line 5

def get_combination_cards(cards)
  same_suit = cards_by_suit.find do |suit, cards_of_same_suit|
    cards_of_same_suit.length >= 5
  end
  same_suit ? same_suit[1].sort.last(5) : []
end