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
|
# File 'lib/bucs_roster/cli.rb', line 8
def
@pointer ||= 0
Player.all[@pointer,30].each.with_index(@pointer+1) do |player, index|
puts "#{index}. #{player.name}"
end
puts "Enter the number of the player you would like to know more about, '+' for next group, '-' for previous group or type 'exit' to end."
user_input = gets.strip
case user_input
when "exit"
goodbye
when "+"
@pointer += 30
@pointer = (Player.all.count)-30 if @pointer > Player.all.count
when "-"
@pointer -= 30
@pointer = 0 if @pointer < 0
end
user_input = user_input.to_i
if user_input.between?(1, Player.all.count)
user_input -=1
Scraper.scrape_player(user_input)
Player.show_player_info(user_input)
ask_again
else
puts "Invalid entry. Please try again."
end
end
|