Class: TexasHoldem::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/game.rb

Constant Summary collapse

SMALL_BLIND_PERCENTAGE =
0.0125

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(players, entrance_fee) ⇒ Game

Returns a new instance of Game.



5
6
7
# File 'lib/game.rb', line 5

def initialize(players,entrance_fee)
  @players, @entrance_fee = players, entrance_fee
end

Instance Attribute Details

#entrance_feeObject (readonly)

Returns the value of attribute entrance_fee.



3
4
5
# File 'lib/game.rb', line 3

def entrance_fee
  @entrance_fee
end

#playersObject (readonly)

Returns the value of attribute players.



3
4
5
# File 'lib/game.rb', line 3

def players
  @players
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/game.rb', line 9

def finished?
  players.size == 1
end

#small_blindObject



17
18
19
# File 'lib/game.rb', line 17

def small_blind
  @entrance_fee * SMALL_BLIND_PERCENTAGE
end

#winnerObject



13
14
15
# File 'lib/game.rb', line 13

def winner
  players.first if finished?
end