Class: AcpcPokerTypes::ChipStack

Inherits:
Rational
  • Object
show all
Defined in:
lib/acpc_poker_types/chip_stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(number_of_chips = 0) ⇒ ChipStack

Returns a new instance of ChipStack.

Parameters:

  • number_of_chips (#to_i) (defaults to: 0)

    The number of chips to be made into a stack.

Raises:

  • IllegalNumberOfChips



10
11
12
13
14
15
16
# File 'lib/acpc_poker_types/chip_stack.rb', line 10

def initialize(number_of_chips=0)
  @value = number_of_chips.to_i

  assert_valid_value

  super @value
end

Instance Method Details

#give!(number_of_chips) ⇒ Object



27
28
29
# File 'lib/acpc_poker_types/chip_stack.rb', line 27

def give!(number_of_chips)
  receive!(-number_of_chips)
end

#receive!(number_of_chips) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/acpc_poker_types/chip_stack.rb', line 18

def receive!(number_of_chips)
  @value += number_of_chips

  assert_valid_value

  __setobj__ @value

  self
end