Class: HandType
- Inherits:
-
Object
- Object
- HandType
- Defined in:
- lib/rora/model/hand_type.rb
Overview
The nine different types of 5-card poker hand.
A 5-card poker hand will be one of the following hand types:
-
High Card
-
One Pair
-
Two Pair
-
Three of a Kind
-
Straight
-
Flush
-
Full House
-
Four of a Kind
-
Straight Flush
Constant Summary collapse
- HIGH_CARD =
new("HC", "High Card", 1)
- ONE_PAIR =
new("1P", "One Pair", 2)
- TWO_PAIR =
new("2P", "Two Pair", 3)
- THREE_OF_A_KIND =
new("3K", "Three of a Kind", 4)
- STRAIGHT =
new("ST", "Straight", 5)
- FLUSH =
new("FL", "Flush", 6)
- FULL_HOUSE =
new("FH", "Full House", 7)
- FOUR_OF_A_KIND =
new("4K", "Four of a Kind", 8)
- STRAIGHT_FLUSH =
new("SF", "Straight Flush", 9)
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, value, order) ⇒ HandType
constructor
A new instance of HandType.
- #to_s ⇒ Object
Constructor Details
#initialize(key, value, order) ⇒ HandType
Returns a new instance of HandType.
19 20 21 22 23 |
# File 'lib/rora/model/hand_type.rb', line 19 def initialize(key, value, order) @key = key @value = value @order = order end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
17 18 19 |
# File 'lib/rora/model/hand_type.rb', line 17 def key @key end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
17 18 19 |
# File 'lib/rora/model/hand_type.rb', line 17 def order @order end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
17 18 19 |
# File 'lib/rora/model/hand_type.rb', line 17 def value @value end |
Class Method Details
.get(key) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rora/model/hand_type.rb', line 29 def self.get(key) self.values.each do |type| return type if type.key.casecmp(key) == 0 end raise ArgumentError, "No hand type exists for key '#{key}'" end |
.values ⇒ Object
25 26 27 |
# File 'lib/rora/model/hand_type.rb', line 25 def self.values [HIGH_CARD, ONE_PAIR, TWO_PAIR, THREE_OF_A_KIND, STRAIGHT, FLUSH, FULL_HOUSE, FOUR_OF_A_KIND, STRAIGHT_FLUSH] end |
Instance Method Details
#to_s ⇒ Object
36 37 38 |
# File 'lib/rora/model/hand_type.rb', line 36 def to_s "HandType: key='#{@key}', value='#{@value}'" end |