Class: Holdem::PokerHand
- Inherits:
-
Object
- Object
- Holdem::PokerHand
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/holdem/poker_hand.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
-
#poker_rank ⇒ Object
readonly
Returns the value of attribute poker_rank.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #count ⇒ Object
-
#initialize(cards) ⇒ PokerHand
constructor
A new instance of PokerHand.
- #just_cards ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cards) ⇒ PokerHand
Returns a new instance of PokerHand.
15 16 17 18 |
# File 'lib/holdem/poker_hand.rb', line 15 def initialize(cards) @cards = cards.is_a?(String) ? CardGenerator.build(cards.split) : cards @poker_rank = PokerRank.new(@cards) end |
Instance Attribute Details
#cards ⇒ Object (readonly)
Returns the value of attribute cards.
13 14 15 |
# File 'lib/holdem/poker_hand.rb', line 13 def cards @cards end |
#poker_rank ⇒ Object (readonly)
Returns the value of attribute poker_rank.
13 14 15 |
# File 'lib/holdem/poker_hand.rb', line 13 def poker_rank @poker_rank end |
Instance Method Details
#<=>(other) ⇒ Object
24 25 26 |
# File 'lib/holdem/poker_hand.rb', line 24 def <=>(other) score <=> other.score end |
#count ⇒ Object
20 21 22 |
# File 'lib/holdem/poker_hand.rb', line 20 def count cards.size end |
#just_cards ⇒ Object
28 29 30 |
# File 'lib/holdem/poker_hand.rb', line 28 def just_cards "#{cards.map{ |card| card.to_s }.join(' ')}" end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/holdem/poker_hand.rb', line 32 def to_s "#{just_cards} -> #{rank}" end |