-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.rb
39 lines (37 loc) · 1.17 KB
/
app.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
require_relative './src/modules/book_options'
require_relative './src/modules/people_options'
require_relative './src/modules/rental_options'
require_relative './src/modules/storage'
class App
def initialize(options)
@options = options
@book_options = BookOptions.new
@people_options = PeopleOptions.new
@rentals_list = RentalOptions.new(@book_options, @people_options)
@book_options.books_list = Storage.load_data('books')
@people_options.people_list = Storage.load_data('person')
@rentals_list.rentals_list = Storage.load_data('rental')
end
def select_option(user_choice)
case user_choice
when '1'
@book_options.list_all_books
when '2'
@people_options.list_all_people
when '3'
@people_options.create_person
Storage.save_date('person', @people_options.people_list)
when '4'
@book_options.create_book
Storage.save_date('books', @book_options.books_list)
when '5'
@rentals_list.create_rental
Storage.save_date('rental', @rentals_list.rentals_list)
when '6'
@rentals_list.list_all_rentals
else
puts 'Invalid option, please try again!'
end
@options.show_menu
end
end