Class: TwentyOne::Bet
- Inherits:
-
Object
- Object
- TwentyOne::Bet
- Defined in:
- lib/twenty_one/bet.rb
Instance Attribute Summary collapse
-
#chips ⇒ Object
readonly
Returns the value of attribute chips.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ Bet
constructor
A new instance of Bet.
- #payout(type) ⇒ Object
- #present(chips) ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize ⇒ Bet
Returns a new instance of Bet.
8 9 10 |
# File 'lib/twenty_one/bet.rb', line 8 def initialize() @chips = [] end |
Instance Attribute Details
#chips ⇒ Object (readonly)
Returns the value of attribute chips.
6 7 8 |
# File 'lib/twenty_one/bet.rb', line 6 def chips @chips end |
Instance Method Details
#clear ⇒ Object
40 41 42 |
# File 'lib/twenty_one/bet.rb', line 40 def clear @chips = [] end |
#payout(type) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/twenty_one/bet.rb', line 20 def payout(type) res = [] if type == :twenty_one payout_generator = Player.new "Temporary player" payout_generator.make_bet value * 2.5 res.concat payout_generator.bet.chips payout_generator = nil elsif type == :push res.concat @chips else 2.times do res.concat @chips end end @chips = [] res end |
#present(chips) ⇒ Object
12 13 14 |
# File 'lib/twenty_one/bet.rb', line 12 def present(chips) @chips = chips end |
#value ⇒ Object
16 17 18 |
# File 'lib/twenty_one/bet.rb', line 16 def value Chip.get_amount(@chips) end |