Class: Pot
- Inherits:
-
Object
- Object
- Pot
- Defined in:
- lib/rora/model/pot.rb
Overview
The sum of money that players wager during a single hand or game.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#add(bet) ⇒ Object
Adds the specified bet to the pot.
-
#initialize ⇒ Pot
constructor
A new instance of Pot.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Pot
Returns a new instance of Pot.
7 8 9 |
# File 'lib/rora/model/pot.rb', line 7 def initialize @value = 0 end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/rora/model/pot.rb', line 5 def value @value end |
Instance Method Details
#add(bet) ⇒ Object
Adds the specified bet to the pot
12 13 14 15 16 |
# File 'lib/rora/model/pot.rb', line 12 def add bet raise ArgumentError, "Can only add positive values" if bet < 0 @value += bet self end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/rora/model/pot.rb', line 18 def to_s "Pot: " + sprintf("$%.02f" , @value) end |