Class: NCAABasketball
- Inherits:
-
Object
- Object
- NCAABasketball
- Defined in:
- lib/ncaa_scrape.rb
Instance Attribute Summary collapse
-
#division_one_data ⇒ Object
readonly
Returns the value of attribute division_one_data.
Instance Method Summary collapse
-
#initialize ⇒ NCAABasketball
constructor
A new instance of NCAABasketball.
- #pick_five_total(*teams) ⇒ Object
- #team_names ⇒ Object
- #team_wins(team_name) ⇒ Object
Constructor Details
#initialize ⇒ NCAABasketball
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_data ⇒ Object (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_names ⇒ Object
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 |