Class: NbaDrilldown::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/nba_drilldown/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



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
# File 'lib/nba_drilldown/cli.rb', line 3

def call
  NbaDrilldown::Team.create_teams if NbaDrilldown::Team.all.empty?
  
  #scrape_website
  puts "Welcome to NBA Drilldown!"
  
  puts "Please enter the number for a team to see its players or type 31 to exit"
  NbaDrilldown::Team.list_teams
  puts "31. Exit!!!"

  input = gets.chomp.to_i
   if input == 31
    puts "Goodbye!"
  elsif (1..30).include?(input)
    team = NbaDrilldown::Team.find_team(input)
    team.create_players_from_team
    puts "The players of the #{team.name}"
     team.list_players
     continue?
  else
      puts "I am sorry please enter a valid team number"

    
  end
  

 
end

#continue?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
# File 'lib/nba_drilldown/cli.rb', line 34

def continue?
puts "Would you like to look at another team? Yes to return or No to exit."
  input = gets.chomp
  if input.downcase.capitalize == "Yes"
    call
  else
    puts "Goodbye!"
  end
end

#scrape_websiteObject



44
45
46
47
48
# File 'lib/nba_drilldown/cli.rb', line 44

def scrape_website
  #NbaDrilldown::Conference.create_by_scraping
  NbaDrilldown::Team.create_teams
  NbaDrilldown::Team.create_players_from_team_url
end