Class: Vvm::State::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vvm/state/base.rb

Direct Known Subclasses

EmptyBalance, PositiveBalance, SoldOut

Instance Method Summary collapse

Constructor Details

#initialize(machine) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/vvm/state/base.rb', line 10

def initialize(machine)
  @machine = machine
end

Instance Method Details

#dispenseObject



22
23
24
25
26
27
28
# File 'lib/vvm/state/base.rb', line 22

def dispense
  result = Vvm::Dispenser.new(balance, coins).call

  machine.balance -= result.sum { _1.qty * _1.value }

  result
end

#insert(coin) ⇒ Object

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/vvm/state/base.rb', line 14

def insert(coin)
  raise NotImplementedError
end

#pick(product_name) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/vvm/state/base.rb', line 18

def pick(product_name)
  raise NotImplementedError
end