-
Notifications
You must be signed in to change notification settings - Fork 0
/
spanish_omlette.rb
112 lines (93 loc) · 2.95 KB
/
spanish_omlette.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
def print_divider
puts "*" * 40
puts "\n"
end
def print_progress_bar
3.times { sleep 0.5; print "." }
puts "\n"
end
NUM_POTATOES = 5
NUM_EGGS = 6
ingredients = [
{ name: 'potatoes', quantity: NUM_POTATOES },
{ name: 'eggs', quantity: NUM_EGGS },
{ name: 'onion', quantity: 1 },
{ name: 'oil', quantity: 'some' },
{ name: 'salt', quantity: 'some' },
]
puts "* Let's cook a Spanish Omelette! *"
print_divider
puts "You need the following ingredients: "
ingredients.each do |ingredient|
puts "* #{ingredient[:quantity]} #{ingredient[:name]}"
end
loop do
puts "\n"
print_divider
puts "Got all ingredients you need? (Y/N)"
answer = gets.chomp.upcase
if answer == 'N'
puts "You need to go shopping"
print_progress_bar
elsif answer == 'Y'
puts "Let's start cooking!"
break
else
puts "That's not a valid input. Try again."
end
end
steps = [
{ description: "Scrape potatoes", action: "scrape_potatoes" },
{ description: "Cut potatoes into thick slices", action: "cut_potatoes" },
{ description: "Chop the onion", action: "generic_recipe_step" },
{ description: "Heat the oil in a large frying pan", action: "generic_recipe_step" },
{ description: "Add potatoes to the pan", action: "add_potatoes_to_pan" },
{ description: "Add onion to the pan", action: "generic_recipe_step" },
{ description: "Strain potatoes and onions through a colander into a large bowl", action: "generic_recipe_step" },
{ description: "Break the eggs", action: "break_eggs" },
{ description: "Beat the eggs separately", action: "generic_recipe_step" },
{ description: "Stir into the bowl the potatoes with plenty of salt", action: "generic_recipe_step" },
{ description: "Heat a little of the strained oil in a smaller pan", action: "generic_recipe_step" },
{ description: "Tip everything into the pan and cook on a moderate heat", action: "generic_recipe_step"},
{ description: "When almost set, invert on a plate and slide back into the pan", action: "generic_recipe_step" },
{ description: "Cook a few more minutes and slide on to a plate and cool for 10 minutes before serving", action: "generic_recipe_step" }
]
print_divider
puts "See below the different steps to follow:"
steps.each_with_index do |step, index|
puts (index + 1).to_s + ") " + step[:description]
end
def generic_recipe_step
puts "On it!"
print_progress_bar
end
def scrape_potatoes
counter = 0
while counter < NUM_POTATOES
counter += 1
print "Scraping potato #{counter}"
print_progress_bar
end
end
def cut_potatoes
counter = 0
while counter < NUM_POTATOES
counter += 1
print "Cutting potato #{counter} into thick slices"
print_progress_bar
end
end
def add_potatoes_to_pan
for counter in 1..NUM_POTATOES
print "Adding potato #{counter} to the pan."
print_progress_bar
end
end
def break_eggs
counter = 0
while counter < NUM_EGGS
counter += 1
print "Breaking egg #{counter}"
print_progress_bar
end
end