class Rank::HandRank

Public Class Methods

new(hand) click to toggle source
# File lib/rank/hand_rank.rb, line 4
def initialize(hand)
  @hand = hand
end

Public Instance Methods

<=>(hand) click to toggle source
# File lib/rank/hand_rank.rb, line 12
def <=>(hand)
  hand_1 = @hand.only_values.sort.join('').to_i
  hand_2 = hand.only_values.sort.join('').to_i
  hand_1 <=> hand_2
end
only_values() click to toggle source
# File lib/rank/hand_rank.rb, line 8
def only_values
  @hand.cards.map { |card| card.value}
end