-
Notifications
You must be signed in to change notification settings - Fork 0
/
shopping_list.rb
37 lines (31 loc) · 1.06 KB
/
shopping_list.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require_relative 'find_food'
module Shopping_list
SHOPPING_COMAND = 'shopping'
module_function
def edit_shopping_list pantry, shopping_list, item, amount
shortage = (amount.to_f-Find_food.get_stock(pantry,item))
if shortage > 0
shopping_list.store(item, shortage)
end
return shopping_list
end
def list_for_recipe pantry
shopping_list = {}
puts "Please enter required ingedients (one ingredient at a time). Enter 'DONE' when finished".colorize(:color => :light_green, :background => :light_black)
while true
puts "Recipe Ingredient:".colorize(:color => :light_green, :background => :light_black)
item = gets.strip.downcase
if item == "done"
break
end
puts "Amount:".colorize(:color => :light_green, :background => :light_black)
amount = gets.strip
if amount == "done"
break
end
edit_shopping_list(pantry, shopping_list, item, amount)
end
puts "Here is your shopping list:\n"
shopping_list.each {|key, value| puts "#{key} : #{value}".colorize(:light_yellow) }
end
end