Class: NCAABasketball

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNCAABasketball

Returns a new instance of NCAABasketball.



7
8
9
10
# File 'lib/ncaa_scrape.rb', line 7

def initialize
  @standings_page = Nokogiri::HTML(open('http://www.ncaa.com/standings/basketball-men/d1'))
  @division_one_data = team_names.zip(wins).to_h
end

Instance Attribute Details

#division_one_dataObject (readonly)

Returns the value of attribute division_one_data.



5
6
7
# File 'lib/ncaa_scrape.rb', line 5

def division_one_data
  @division_one_data
end

Instance Method Details

#pick_five_total(*teams) ⇒ Object



22
23
24
# File 'lib/ncaa_scrape.rb', line 22

def pick_five_total(*teams)
  teams.inject(0) { |total, team| total + team_wins(team) }
end

#team_namesObject



12
13
14
15
16
# File 'lib/ncaa_scrape.rb', line 12

def team_names
  names = []
  raw_data.each { |row| names << row[0] }
  names
end

#team_wins(team_name) ⇒ Object



18
19
20
# File 'lib/ncaa_scrape.rb', line 18

def team_wins(team_name)
  @division_one_data.include?(team_name) ? @division_one_data[team_name] : 0
end