forked from nmajor/food-delivery-april-25
-
Notifications
You must be signed in to change notification settings - Fork 1
/
router.rb
59 lines (52 loc) · 1.24 KB
/
router.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
class Router
def initialize(meals_controller, sessions_controller)
@meals_controller = meals_controller
@sessions_controller = sessions_controller
@running = true
end
def run
employee = @sessions_controller.sign_in
while @running
if employee.role == 'manager'
display_manager_options
action = gets.chomp
route_manager_action(action)
else
display_delivery_guy_options
action = gets.chomp
route_delivery_guy_action(action)
end
end
end
def route_manager_action(action)
case action
when '1' then @meals_controller.list
when '2' then @meals_controller.create
when '3', 'exit', 'stop', 'clear'
stop
end
end
def route_delivery_guy_action(action)
case action
when '1' then puts "TODO list my orders"
when '2' then puts "TODO mark as delivered"
when '3', 'exit', 'stop', 'clear'
stop
end
end
def display_manager_options
puts '1 - List Meals'
puts '2 - Add Meal'
puts '3 - Exit Program'
print '> '
end
def display_delivery_guy_options
puts '1 - List my orders'
puts '2 - Mark order as delivered'
puts '3 - Exit Program'
print '> '
end
def stop
@running = false
end
end