class Deck::Hand

Attributes

cards[R]
rank[R]

Public Class Methods

new(hand_cards) click to toggle source
# File lib/deck/hand.rb, line 9
def initialize(hand_cards)
  @cards = hand_cards
  @rank = select_rank
end

Public Instance Methods

only_values() click to toggle source
# File lib/deck/hand.rb, line 14
def only_values
  @cards.map { |card| card.value}
end

Private Instance Methods

<=>(hand) click to toggle source
# File lib/deck/hand.rb, line 32
def <=>(hand)
  self.rank <=> hand.rank
end
select_rank() click to toggle source
# File lib/deck/hand.rb, line 20
def select_rank
  return Rank::StraightFlush.new(self) if is_straight_flush?
  return Rank::FourOfAKind.new(self) if is_four_of_a_kind?
  return Rank::FullHouse.new(self) if is_full_house?
  return Rank::Flush.new(self) if is_flush?
  return Rank::Straight.new(self) if is_straight?
  return Rank::ThreeOfAKind.new(self) if is_three_of_a_kind?
  return Rank::TwoPairs.new(self) if is_two_pairs?
  return Rank::Pair.new(self) if is_pair?
  Rank::HighCard.new(self)
end