Class: Vvm::CLI::Command::ShowProducts

Inherits:
Base
  • Object
show all
Defined in:
lib/vvm/cli/command/pick_product.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
# File 'lib/vvm/cli/command/pick_product.rb', line 9

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

  result = prompt.select('Please select', inventory_choices.push({ name: 'Back', value: :back }))

  if result == :back
    env.call(:show_main_menu)
  else
    env.call(:confirm_product_pick, { picked_product: machine.pick(result) })
  end
end