-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rb
50 lines (44 loc) · 1.02 KB
/
main.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
require './app'
require './logic'
def exit_app(app)
app.exit
puts 'Data saved, Thank you & Call Again'
false
end
def options
[
'',
'Please choose an option by entering a number:',
'1 - List all books',
'2 - List all people',
'3 - Create a person',
'4 - Create a book',
'5 - Create a rental',
'6 - List all rentals for a given person id',
'7 - Save and Exit'
]
end
# rubocop:disable Metrics/CyclomaticComplexity
def main
app = App.new
puts 'Welcome to School Library App.'
app_should_run = true
while app_should_run
puts options
user_selection = gets.to_i
case user_selection
when 1 then list_books(app.books)
when 2 then list_people(app.people)
when 3 then create_person(app)
when 4 then create_book(app)
when 5 then create_rental(app)
when 6 then list_rentals(app)
when 7
app_should_run = exit_app(app)
break
else puts 'Please input a number between 1 and 7'
end
end
# rubocop:enable Metrics/CyclomaticComplexity
end
main