Class: NbaSchedule
- Inherits:
-
Object
- Object
- NbaSchedule
- Includes:
- NbaUrls, PrintUtils
- Defined in:
- lib/hoopscrape/NbaSchedule.rb
Overview
Access NBA team schedule data
Instance Attribute Summary collapse
-
#allGames ⇒ Navigator
readonly
Navigator All Schedule data.
-
#futureGames ⇒ Navigator
readonly
Navigator for Future Games.
-
#game_list ⇒ Object
readonly
Returns the value of attribute game_list.
-
#losses ⇒ Object
readonly
Returns the value of attribute losses.
-
#next_game ⇒ Object
readonly
Returns the value of attribute next_game.
-
#pastGames ⇒ Navigator
readonly
Return Schedule info of Past Games.
-
#wins ⇒ Object
readonly
Returns the value of attribute wins.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(args) ⇒ NbaSchedule
constructor
Read Schedule data for a given Team.
-
#lastGame ⇒ Object
Returns Schedule info of last completed game.
-
#nextGame ⇒ [Object]
Returns Schedule info of next game.
-
#nextGameId ⇒ Integer
Game # of Next Game.
-
#nextTeamId ⇒ String
Team ID of next opponent.
Methods included from PrintUtils
Methods included from NbaUrls
#adjustTeamName, #boxScoreUrl, #checkSpecial, #formatTeamUrl, #getTid, #playerUrl, #seasonYearEnd, #seasonYears, #teamListUrl, #teamRosterUrl, #teamScheduleUrl
Constructor Details
#initialize(args) ⇒ NbaSchedule
Season Types: 1-Preseason; 2-Regular Season; 3-Playoffs
Read Schedule data for a given Team
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 20 def initialize(args) doc, seasontype = getNokoDoc(args) return if doc.nil? @game_list = [] # Processed Schedule Data @next_game = 0 # Cursor to start of Future Games schedule, @year, indicator, tid = collectNodeSets(doc) season_valid = verifySeasonType(seasontype, indicator) seasontype = findSeasonType(indicator) if seasontype.to_i.eql?(0) @wins = @losses = 0 processSeason(schedule, tid, @year, seasontype, args[:format]) if season_valid && !seasontype.eql?(0) @allGames = Navigator.new(@game_list) @futureGames = Navigator.new(@game_list[@next_game, game_list.size]) @pastGames = Navigator.new(@game_list[0, @next_game]) @game_list = nil @year = "#{@year}-#{(@year + 1).to_s[2, 4]}" end |
Instance Attribute Details
#allGames ⇒ Navigator (readonly)
Returns Navigator All Schedule data.
43 44 45 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 43 def allGames @allGames end |
#futureGames ⇒ Navigator (readonly)
Returns Navigator for Future Games.
80 81 82 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 80 def futureGames @futureGames end |
#game_list ⇒ Object (readonly)
Returns the value of attribute game_list.
7 8 9 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 7 def game_list @game_list end |
#losses ⇒ Object (readonly)
Returns the value of attribute losses.
7 8 9 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 7 def losses @losses end |
#next_game ⇒ Object (readonly)
Returns the value of attribute next_game.
7 8 9 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 7 def next_game @next_game end |
#pastGames ⇒ Navigator (readonly)
Return Schedule info of Past Games
86 87 88 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 86 def pastGames @pastGames end |
#wins ⇒ Object (readonly)
Returns the value of attribute wins.
7 8 9 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 7 def wins @wins end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
7 8 9 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 7 def year @year end |
Instance Method Details
#lastGame ⇒ Object
Returns Schedule info of last completed game
61 62 63 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 61 def lastGame allGames[][@next_game - 1] end |
#nextGame ⇒ [Object]
Returns Schedule info of next game
51 52 53 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 51 def nextGame allGames[][@next_game] unless allGames[].nil? end |
#nextGameId ⇒ Integer
Returns Game # of Next Game.
66 67 68 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 66 def nextGameId @next_game end |
#nextTeamId ⇒ String
Returns Team ID of next opponent.
73 74 75 |
# File 'lib/hoopscrape/NbaSchedule.rb', line 73 def nextTeamId nextGame[4] if nextGame end |