Class: OfcpScoring::OrganizedHand
- Inherits:
-
Object
- Object
- OfcpScoring::OrganizedHand
- Includes:
- Enumerable
- Defined in:
- lib/ofcp_scoring/organized_hand.rb
Instance Method Summary collapse
- #all_suits_match? ⇒ Boolean
- #four_cards_match? ⇒ Boolean
-
#initialize(organized_hand) ⇒ OrganizedHand
constructor
A new instance of OrganizedHand.
- #ranks ⇒ Object
- #ranks_in_order? ⇒ Boolean
- #sequences ⇒ Object
- #suits ⇒ Object
- #three_card_hand? ⇒ Boolean
- #three_cards_match? ⇒ Boolean
- #two_cards_match? ⇒ Boolean
- #two_different_cards_match? ⇒ Boolean
Constructor Details
#initialize(organized_hand) ⇒ OrganizedHand
Returns a new instance of OrganizedHand.
4 5 6 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 4 def initialize(organized_hand) @hand = organized_hand end |
Instance Method Details
#all_suits_match? ⇒ Boolean
41 42 43 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 41 def all_suits_match? @hand[:all_suits_match] end |
#four_cards_match? ⇒ Boolean
37 38 39 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 37 def four_cards_match? @hand[:four_cards_match] end |
#ranks ⇒ Object
8 9 10 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 8 def ranks @hand[:ranks] end |
#ranks_in_order? ⇒ Boolean
45 46 47 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 45 def ranks_in_order? @hand[:ranks_in_order] end |
#sequences ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 12 def sequences ranks = @hand[:ranks].reverse prev = ranks[0] ranks.slice_before { |cur| prev, prev2 = cur, prev prev2 - 1 != prev }.to_a end |
#suits ⇒ Object
21 22 23 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 21 def suits @hand[:suits] end |
#three_card_hand? ⇒ Boolean
49 50 51 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 49 def three_card_hand? @hand[:three_card_hand] end |
#three_cards_match? ⇒ Boolean
33 34 35 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 33 def three_cards_match? @hand[:three_cards_match] end |
#two_cards_match? ⇒ Boolean
25 26 27 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 25 def two_cards_match? @hand[:two_cards_match] end |
#two_different_cards_match? ⇒ Boolean
29 30 31 |
# File 'lib/ofcp_scoring/organized_hand.rb', line 29 def two_different_cards_match? @hand[:two_different_cards_match] end |