Class: TexasHoldem::PlayerHand

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/texas-holdem/player_hand.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cards) ⇒ PlayerHand

Returns a new instance of PlayerHand.



6
7
8
9
# File 'lib/texas-holdem/player_hand.rb', line 6

def initialize(cards)
  @cards = cards
  @best_combination = get_best_combination
end

Instance Attribute Details

#best_combinationObject (readonly)

Returns the value of attribute best_combination.



4
5
6
# File 'lib/texas-holdem/player_hand.rb', line 4

def best_combination
  @best_combination
end

#cardsObject (readonly)

Returns the value of attribute cards.



4
5
6
# File 'lib/texas-holdem/player_hand.rb', line 4

def cards
  @cards
end

Instance Method Details

#<=>(other) ⇒ Object



16
17
18
# File 'lib/texas-holdem/player_hand.rb', line 16

def <=>(other)
  best_combination <=> other.best_combination
end

#add_cards(cards) ⇒ Object



11
12
13
14
# File 'lib/texas-holdem/player_hand.rb', line 11

def add_cards(cards)
  @cards.push(*cards)
  @best_combination = get_best_combination
end