Class: Vvm::CLI::Command::ShowMainMenu

Inherits:
Base
  • Object
show all
Defined in:
lib/vvm/cli/command/show_main_menu.rb

Instance Attribute Summary

Attributes inherited from Base

#env

Instance Method Summary collapse

Methods inherited from Base

by_command_name, inherited, #initialize

Constructor Details

This class inherits a constructor from Vvm::CLI::Command::Base

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vvm/cli/command/show_main_menu.rb', line 9

def call
  prompt.say("Balance: $#{machine.balance}")

  choices = [
    { name: 'Insert a coin', value: :insert_coin, **maybe_out_of_stock },
    { name: 'Pick the product', value: :pick_product },
    { name: 'Dispense', value: :dispense, **maybe_empty_balance, **maybe_no_change },
    { name: 'Exit', value: :exit }
  ]

  result = prompt.select('Main menu:', choices)

  env.call(result)
end