Class: OfcpScoring::Pair

Inherits:
RankedHand show all
Defined in:
lib/ofcp_scoring/pair.rb

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

Constructor Details

This class inherits a constructor from OfcpScoring::RankedHand

Instance Method Details

#<=>(other) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/ofcp_scoring/pair.rb', line 3

def <=>(other)
  return super if super
  if highest_paired_card == other.highest_paired_card
    compare_ranks(other)
  else
    highest_paired_card <=> other.highest_paired_card
  end
end

#highest_paired_cardObject



12
13
14
# File 'lib/ofcp_scoring/pair.rb', line 12

def highest_paired_card
  grouped_ranks.map{|card,matches| card if matches.size == 2}.compact.first
end