Class: TexasHoldem::ThreeOfAKind

Inherits:
PlayerHand show all
Defined in:
lib/player_hand.rb

Constant Summary collapse

Pattern =
/(\d{1,2})[scdh] (?:\s\1[scdh]){2}/x

Instance Attribute Summary

Attributes inherited from PlayerHand

#cards

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PlayerHand

#<=>, inherited, #initialize, #remaining_cards, #score

Constructor Details

This class inherits a constructor from TexasHoldem::PlayerHand

Class Method Details

.create(cards) ⇒ Object



138
139
140
# File 'lib/player_hand.rb', line 138

def self.create(cards)
  new(cards) if cards.match Pattern
end

Instance Method Details

#base_scoreObject



146
147
148
# File 'lib/player_hand.rb', line 146

def base_score
  3
end

#nameObject



142
143
144
# File 'lib/player_hand.rb', line 142

def name
  'three of a kind'
end

#relative_scoreObject



150
151
152
# File 'lib/player_hand.rb', line 150

def relative_score
  @cards[ Pattern, 1 ].to_i
end