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
|
# File 'lib/classes/List.rb', line 6
def self.(data)
loop do
list_prompt = TTY::Prompt.new(active_color: :red)
user_input = list_prompt.select("How would you like to list the Pokemon?\nPlease enter one of the following options.") do ||
.choice 'List all', 1
.choice 'List by Type', 2
.choice 'List by Secondary Type', 3
.choice 'List by Generation', 4
.choice 'List Legendary Pokemon', 5
end
case user_input
when 1
puts '-' * 40
puts 'Listing all Pokemon'
puts '-' * 40
list_all(data)
Main_menu.return?
when 2
puts 'Which Type would you like to list by?'
user_input = New.add_type
puts '-' * 40
puts "Listing by #{user_input} Type:"
puts '-' * 40
list_by(data, :type_1, user_input)
Main_menu.return?
when 3
puts 'Which Secondary Type would you like to list by?'
user_input = New.add_type
puts '-' * 40
puts "Listing by #{user_input} Secondary Type:"
puts '-' * 40
list_by(data, :type_2, user_input)
Main_menu.return?
when 4
loop do
user_input = list_prompt.ask("Which generation would you like to list by?\nInput a number between 1-8.") { |q| q.in('1-8') }
puts '-' * 40
puts "Listing by Generation #{user_input}"
puts '-' * 40
list_by(data, :generation, user_input.to_i)
Main_menu.return?
end
when 5
puts '-' * 40
puts 'Listing Legendary Pokemon'
puts '-' * 40
list_by(data, :legendary, 'True')
Main_menu.return?
else
puts 'Invalid selection, please enter a number between 1-5.'
end
end
end
|