Class: OfcpScoring::TwoPair
Constant Summary
Constants inherited
from RankedHand
RankedHand::RANKINGS
Instance Method Summary
collapse
Methods inherited from RankedHand
#compare_ranks, #grouped_ranks, #initialize, #rank_name, #ranks, #suits
Instance Method Details
#<=>(other) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/ofcp_scoring/two_pair.rb', line 2
def <=>(other)
return super if super
if higher_paired_card == other.higher_paired_card
if lower_paired_card == other.lower_paired_card
compare_ranks(other)
else
lower_paired_card <=> other.lower_paired_card
end
else
higher_paired_card <=> other.higher_paired_card
end
end
|
#higher_paired_card ⇒ Object
15
16
17
|
# File 'lib/ofcp_scoring/two_pair.rb', line 15
def higher_paired_card
grouped_ranks.map{|card,matches| card if matches.size == 2}.compact.max
end
|
#lower_paired_card ⇒ Object
19
20
21
|
# File 'lib/ofcp_scoring/two_pair.rb', line 19
def lower_paired_card
grouped_ranks.map{|card,matches| card if matches.size == 2}.compact.min
end
|