Class: PokerRanking::HandType::Flush
- Inherits:
-
Base
- Object
- Base
- PokerRanking::HandType::Flush
show all
- Defined in:
- lib/hand_type/flush.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#cards
Instance Method Summary
collapse
Methods inherited from Base
#cards_for_values_and_kickers, #cards_in_straight, #highest_same_value, #highest_same_value_except, #initialize, #n_of_a_kind?, #number_of_kickers, #second_value, #straight_value_of
Instance Attribute Details
#flush_suit ⇒ Object
Returns the value of attribute flush_suit.
5
6
7
|
# File 'lib/hand_type/flush.rb', line 5
def flush_suit
@flush_suit
end
|
Instance Method Details
#cards_used ⇒ Object
46
47
48
|
# File 'lib/hand_type/flush.rb', line 46
def cards_used
cards.select { |card| card.suit == @flush_suit }[-5..-1]
end
|
#handles? ⇒ Boolean
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/hand_type/flush.rb', line 7
def handles?
count = { 'Hearts' => 0, 'Clubs' => 0, 'Diamonds' => 0, 'Spades' => 0 }
cards.each do |card|
count[card.suit] += 1
end
count.each do |suit, suit_count|
if suit_count >= 5
@flush_suit = suit
return true
end
end
return false
end
|
#kickers ⇒ Object
only use kickers that are of the suit
28
29
30
31
32
33
34
35
36
|
# File 'lib/hand_type/flush.rb', line 28
def kickers
kick = []
cards.reverse.each do |card|
if card.suit == @flush_suit
kick << card.value
end
end
kick[0..number_of_kickers-1]
end
|
#name ⇒ Object
42
43
44
|
# File 'lib/hand_type/flush.rb', line 42
def name
'flush'
end
|
#rank ⇒ Object
38
39
40
|
# File 'lib/hand_type/flush.rb', line 38
def rank
5
end
|
#value ⇒ Object
23
24
25
|
# File 'lib/hand_type/flush.rb', line 23
def value
kickers.first
end
|