class OfcpScoring::RankedHand

Constants

RANKINGS

Public Class Methods

new(hand=nil) click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 17
def initialize(hand=nil)
  @hand = hand
end

Public Instance Methods

<=>(other_hand) click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 13
def <=>(other_hand)
  RANKINGS.index(rank_name) <=> RANKINGS.index(other_hand.rank_name) unless rank_name == other_hand.rank_name
end
compare_ranks(other) click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 34
def compare_ranks(other)
  (ranks - (ranks & other.ranks)).max <=> (other.ranks - (ranks & other.ranks)).max
end
grouped_ranks() click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 30
def grouped_ranks
  ranks.group_by{|card| card }
end
rank_name() click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 9
def rank_name
  self.class.to_s.split("::").last
end
ranks() click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 21
def ranks
  ranks = @hand.ranks
  ranks.map{|r| r == 1 ? 14 : r}.sort
end
suits() click to toggle source
# File lib/ofcp_scoring/ranked_hand.rb, line 26
def suits
  suits = @hand.suits
end