Class: Hola::App
- Inherits:
-
Object
- Object
- Hola::App
- Defined in:
- lib/hola/app.rb
Instance Method Summary collapse
-
#initialize(prompt = TTY::Prompt.new) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(prompt = TTY::Prompt.new) ⇒ App
Returns a new instance of App.
12 13 14 |
# File 'lib/hola/app.rb', line 12 def initialize(prompt = TTY::Prompt.new) @prompt = prompt end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hola/app.rb', line 16 def run prompt.say("Hola. It's shopping time 🛍️") loop do selection = Product::Selector.new(prompt).perform cart.add( product_id: selection[:product_id], quantity: selection[:quantity] ) break unless prompt.yes?("Would you like to add more items?") end prompt.say(Cart::Renderer.new(cart).perform) end |