Class: NbaTeamList
- Inherits:
-
Object
- Object
- NbaTeamList
- Includes:
- NbaUrls, PrintUtils
- Defined in:
- lib/espnscrape/NbaTeamList.rb
Overview
Access list of NBA teams
Instance Attribute Summary collapse
-
#header ⇒ String
Table Title.
-
#teamList ⇒ [[String]]
Table of NBA Teams.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ [String]
constructor
Scrape Team Data.
Methods included from PrintUtils
Methods included from NbaUrls
#boxScoreUrl, #checkSpecial, #formatTeamUrl, #getTid, #playerUrl, #seasonYearEnd, #seasonYears, #teamListUrl, #teamRosterUrl, #teamScheduleUrl
Constructor Details
#initialize(args = {}) ⇒ [String]
Scrape Team Data
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/espnscrape/NbaTeamList.rb', line 15 def initialize(args = {}) doc = args[:file] ? Nokogiri::HTML(open(args[:file])) : Nokogiri::HTML(open(teamListUrl)) return if doc.nil? # Collect @header = doc.xpath('//h2')[0].text.strip # Table Header team_names = doc.xpath('//h5/a/text()') # Team Names @teamList = [] h = 0 # Head of teamNames range west_conf = %w(Northwest Pacific Southwest) # Western Conference Divs # Process Teams by Division divs = %w(Atlantic Pacific Central Southwest Southeast Northwest) divs.each do |div| @teamList += processTeams(div, team_names[h, 5], west_conf) # Store Team Data h += 5 end # puts "Converting to #{args[:format]}" @teamList = @teamList.send(args[:format], S_TEAM) if args[:format] @teamList = Navigator.new(@teamList) end |