Class: PokerHands::PokerHand
- Inherits:
-
Object
- Object
- PokerHands::PokerHand
- Extended by:
- T::Helpers, T::Sig
- Includes:
- Comparable
- Defined in:
- lib/deck_of_cards_handler/poker_hands/poker_hand.rb
Overview
This represents a poker hands raking
Direct Known Subclasses
Flush, FourOfAKind, FullHouse, HighCard, OnePair, Straight, StraightFlush, ThreeOfAKind, TwoPairs
Constant Summary collapse
- HANDS =
i[OnePair TwoPairs ThreeOfAKind Straight Flush FullHouse FourOfAKind StraightFlush].freeze
Instance Attribute Summary collapse
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(cards:) ⇒ PokerHand
constructor
A new instance of PokerHand.
- #rank ⇒ Object
Constructor Details
#initialize(cards:) ⇒ PokerHand
Returns a new instance of PokerHand.
17 18 19 20 21 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 17 def initialize(cards:) raise ArgumentError if cards.size != 5 @cards = cards end |
Instance Attribute Details
#cards ⇒ Object (readonly)
Returns the value of attribute cards.
14 15 16 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 14 def cards @cards end |
Class Method Details
.build_from_string(string:) ⇒ Object
35 36 37 38 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 35 def build_from_string(string:) cards = Packet.build_from_string(string:).cards PokerHand.create(cards:) end |
.create(cards:) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 55 def create(cards:) HANDS.reverse_each do |hand| return PokerHands.const_get(hand).new(cards:) if PokerHands.const_get(hand).is?(cards) end HighCard.new(cards:) end |
Instance Method Details
#<=>(other) ⇒ Object
26 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 26 def <=>(other); end |
#rank ⇒ Object
29 |
# File 'lib/deck_of_cards_handler/poker_hands/poker_hand.rb', line 29 def rank; end |