Class: TexasHoldem::OnePair

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

Constant Summary collapse

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

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



182
183
184
# File 'lib/player_hand.rb', line 182

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

Instance Method Details

#base_scoreObject



190
191
192
# File 'lib/player_hand.rb', line 190

def base_score
  1
end

#nameObject



186
187
188
# File 'lib/player_hand.rb', line 186

def name
  'one pair'
end

#relative_scoreObject



194
195
196
# File 'lib/player_hand.rb', line 194

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

#remaining_cardsObject



198
199
200
# File 'lib/player_hand.rb', line 198

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