Class: NbaRoster
- Inherits:
-
Object
- Object
- NbaRoster
- Includes:
- NbaUrls, PrintUtils
- Defined in:
- lib/espnscrape/NbaRoster.rb
Overview
Access NBA roster data
Instance Attribute Summary collapse
-
#coach ⇒ String
readonly
Coach Name.
-
#players ⇒ [[String]]
readonly
Returns Team Roster.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ NbaRoster
constructor
Scrape Roster Data.
Methods included from PrintUtils
Methods included from NbaUrls
#boxScoreUrl, #checkSpecial, #formatTeamUrl, #getTid, #playerUrl, #seasonYearEnd, #seasonYears, #teamListUrl, #teamRosterUrl, #teamScheduleUrl
Constructor Details
#initialize(args = {}) ⇒ NbaRoster
Scrape Roster Data
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/espnscrape/NbaRoster.rb', line 20 def initialize(args = {}) if args[:team_id] url = formatTeamUrl(args[:team_id], teamRosterUrl) # Generate URL doc = Nokogiri::HTML(open(url)) # Get DOM elsif args[:file] doc = Nokogiri::HTML(open(args[:file])) end return if doc.nil? team_id ||= getTid(doc.title.split(/\d{4}/).first.strip) list = doc.xpath('//div/div/table/tr') p_list = list[2, list.length - 3] # Get Player Nodes @coach = list[-1].children.first.text.split(':').last.strip # Read Coach Name @players = Navigator.new processPlayerTable(p_list, team_id, args[:format]) end |