vvm 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 255e957bd23e4b4b099fd3cfa5eb3f215eaa94b6032bfcf23ec3479e0a4866a7
4
- data.tar.gz: e4c83101f4f8daea662b07aa5c2ae7677814b6375d38824b6f8cf43fcc47271c
3
+ metadata.gz: 6f2aca61a7c4a442b30ab679077c43515654014c18e0871d99b42b837490b489
4
+ data.tar.gz: ef6fe48c8da6ab1610863c1971387a3b37cf53400018436e64e43e2f58e48c6f
5
5
  SHA512:
6
- metadata.gz: 76f07cb86f35e4425c37ff8f92c46a9b03b3d498eda1e4407484b837479dcd240edfb37ad1835ed7aa4794d28b0278bce206844e2b7dfd9ab7d587fb74de1318
7
- data.tar.gz: 0301b3b61d82540cc78b89520c81882447edd71befa47bf3c35d53c4b46a3c7bc5b59e2ab98a2839dc73739abafc49146028740022cbcea0d80cd16c3e9a188c
6
+ metadata.gz: f5c4b04958d08d707ee588b89bb8cd5b32d86ce5138b4665058ffff4fa12020c2dadc2e7e66b55aaff414f0a97ecc8ce460ff02276a7211e73490b0a0cbfc1a2
7
+ data.tar.gz: 2dc5e6c82774e02647d7aaddc603c8499f1258ae720e536881772b812aaf39ecdbf936db8c074d51047a03d53739f4e653f02c125813b9c52d697a03a89ce998
@@ -9,7 +9,9 @@ module Vvm
9
9
  def call
10
10
  prompt.say("Balance: $#{machine.balance}")
11
11
 
12
- formatted_coins = machine.dispense.filter { _1.qty.positive? }.map { "#{_1.qty} x $#{_1.value}" }.join(', ')
12
+ coins = machine.dispense.filter { _1.qty.positive? }.map { "#{_1.qty} x $#{_1.value}" }
13
+
14
+ formatted_coins = coins.empty? ? '0' : coins.join(', ')
13
15
 
14
16
  env.call(:confirm_dispense, { formatted_coins: formatted_coins })
15
17
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vvm
4
+ class CLI
5
+ module Command
6
+ class Exit < Base
7
+ self.command_name = :exit
8
+
9
+ def call
10
+ exit
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -12,7 +12,8 @@ module Vvm
12
12
  choices = [
13
13
  { name: 'Insert a coin', value: :insert_coin, **maybe_out_of_stock },
14
14
  { name: 'Pick the product', value: :pick_product },
15
- { name: 'Dispense', value: :dispense, **maybe_empty_balance, **maybe_no_change }
15
+ { name: 'Dispense', value: :dispense, **maybe_empty_balance, **maybe_no_change },
16
+ { name: 'Exit', value: :exit }
16
17
  ]
17
18
 
18
19
  result = prompt.select('Main menu:', choices)
data/lib/vvm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vvm
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/vvm.rb CHANGED
@@ -18,3 +18,4 @@ require_relative 'vvm/cli/command/pick_product'
18
18
  require_relative 'vvm/cli/command/dispense'
19
19
  require_relative 'vvm/cli/command/confirm_dispense'
20
20
  require_relative 'vvm/cli/command/confirm_product_pick'
21
+ require_relative 'vvm/cli/command/exit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Bykov
@@ -41,6 +41,7 @@ files:
41
41
  - lib/vvm/cli/command/confirm_dispense.rb
42
42
  - lib/vvm/cli/command/confirm_product_pick.rb
43
43
  - lib/vvm/cli/command/dispense.rb
44
+ - lib/vvm/cli/command/exit.rb
44
45
  - lib/vvm/cli/command/insert_coin.rb
45
46
  - lib/vvm/cli/command/pick_product.rb
46
47
  - lib/vvm/cli/command/show_main_menu.rb