Class: TexasHoldem::TwoPair

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

Constant Summary collapse

Pattern =
/(\d{1,2})[scdh] \1[scdh].*(\d{1,2})[scdh] \2[scdh]/

Instance Attribute Summary

Attributes inherited from PlayerHand

#cards

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PlayerHand

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

Constructor Details

This class inherits a constructor from TexasHoldem::PlayerHand

Class Method Details

.create(cards) ⇒ Object



158
159
160
# File 'lib/player_hand.rb', line 158

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

Instance Method Details

#base_scoreObject



166
167
168
# File 'lib/player_hand.rb', line 166

def base_score
  2 
end

#nameObject



162
163
164
# File 'lib/player_hand.rb', line 162

def name
  'two pair'
end

#relative_scoreObject



170
171
172
# File 'lib/player_hand.rb', line 170

def relative_score
  @cards[ Pattern , 2 ].to_i * 2
end

#remaining_cardsObject



174
175
176
# File 'lib/player_hand.rb', line 174

def remaining_cards
  @cards.gsub(Pattern, '').gsub /\D/, ''
end