generated from ger619/ruby-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
display_menu.rb
85 lines (81 loc) · 1.91 KB
/
display_menu.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
require_relative './exit_app'
require_relative './book'
require_relative './MusicAlbum'
def display_menu(app)
puts "\nWelcome to our Catalog!"
puts "\nPlease choose a task by entering a number:"
puts " 1 - For listing items\n 2 - For adding items\n 3 - Exit App"
choice = gets.chomp
case choice
when '1'
for_listing(app)
when '2'
for_adding(app)
when '3'
exit_app(app)
else
puts 'Invalid selection'
end
end
def for_listing(app)
puts "\nWelcome to our Catalog!"
puts "\nPlease select a number for listing items"
puts " 1 - List all books\n 2 - List all music albums\n 3 - List all games\n 4 - For next menu\n 5 - Back to main\n 6 - Exit App" # rubocop:disable Layout/LineLength
choice = gets.chomp
case choice
when '1'
app.book_display
when '2'
app.music_display
when '3'
app.game_display
when '4'
display_next(app)
when '5'
display_menu(app)
when '6'
exit_app(app)
else
puts 'Invalid selection'
end
end
def display_next(app)
puts "\nWelcome to our Catalog!"
puts "\nPlease select a number for listing items"
puts " 1 - List all authors\n 2 - List all labels\n 3 - List all genres\n 4 - For previous menu\n 5 - Back to main\n 6 - Exit App" # rubocop:disable Layout/LineLength
choice = gets.chomp
case choice
when '1'
app.author_display
when '2'
app.label_display
when '3'
app.genre_display
when '4'
for_listing(app)
when '5'
display_menu(app)
when '6'
exit_app(app)
else
puts 'Invalid selection'
end
end
def for_adding(app)
puts "\nWelcome to our Catalog!"
puts "\nPlease select a number for adding items"
puts " 1 - Add a book\n 2 - Add a music album\n 3 - Add a game\n 4 - Back to main\n 5 - Exit App"
choice = gets.chomp
case choice
when '1'
app.book_create
when '2'
app.music_create
when '3'
app.game_create
when '4'
display_menu(app)
when '5'
exit_app(app)
end
end