-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
51 lines (46 loc) · 1.06 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
51
require_relative 'app'
require_relative 'store/store'
APP = App.new
STORE = Store.new
class Main
def menu_message
puts '____________________________________________________________'
puts 'Please choose an option by entering a number:'
puts '1 - List all books'
puts '2 - List all people'
puts '3 - Create a person'
puts '4 - Create a book'
puts '5 - Create a rental'
puts '6 - List all rentals for a given person id'
puts '7 - Exit'
end
def store_data
STORE.store_books(APP.books)
STORE.store_people(APP.people)
STORE.store_rentals(APP.rentals)
end
def display_menu # rubocop:disable Metrics/CyclomaticComplexity
menu_message
option = gets.chomp.to_i
case option
when 1
APP.list_books
when 2
APP.list_people
when 3
APP.create_person
when 4
APP.create_book
when 5
APP.create_rental
when 6
APP.list_rentals_by_person_id
when 7
store_data
exit
else puts 'Invalid option' end
display_menu
end
end
main = Main.new
main.display_menu