class NBA::Stats::Team

Constants

BASE_URI

Public Class Methods

get_team_by_id(id) click to toggle source
# File lib/nba/stats/team_stats.rb, line 58
def self.get_team_by_id(id)
  teams = get_teams
  teams[id]
end
get_team_stats(measureType="Advanced",perMode="Totals",plusMinus="N",paceAdjust="N",rank="N",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,teamID=0,conference=nil,division=nil,gameSegment=nil,period=0,shotClockRange=nil,lastNGames=0,gameScope=nil,playerExperience=nil,playerPosition=nil,starterBench=nil) click to toggle source

THIS SHOULD BE REFACTORED TO ACCEPT SPLAT PARAMS

# File lib/nba/stats/team_stats.rb, line 5
def self.get_team_stats(measureType="Advanced",perMode="Totals",plusMinus="N",paceAdjust="N",rank="N",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,teamID=0,conference=nil,division=nil,gameSegment=nil,period=0,shotClockRange=nil,lastNGames=0,gameScope=nil,playerExperience=nil,playerPosition=nil,starterBench=nil)
  res = HTTP.get(BASE_URI+'/leaguedashteamstats', :params => {
    :MeasureType => measureType,
    :PerMode => perMode,
    :PlusMinus => plusMinus,
    :PaceAdjust => paceAdjust,
    :Rank => rank,
    :LeagueID => leagueID,
    :Season => season,
    :SeasonType => seasonType,
    :PORound => pORound,
    :Outcome => outcome,
    :Location => location,
    :Month => month,
    :SeasonSegment => seasonSegment,
    :DateFrom => dateFrom,
    :DateTo => dateTo,
    :OpponentTeamID => opponentTeamID,
    :VsConference => vsConference,
    :VsDivision => vsDivision,
    :TeamID => teamID,
    :Conference => conference,
    :Division => division,
    :GameSegment => gameSegment,
    :Period => period,
    :ShotClockRange => shotClockRange,
    :LastNGames => lastNGames,
    :GameScope => gameScope,
    :PlayerExperience => playerExperience,
    :PlayerPosition => playerPosition,
    :StarterBench => starterBench
  })
  if res.code == 200
    return JSON.parse(res.body)
  end
  return res.code
end
get_teams() click to toggle source
# File lib/nba/stats/team_stats.rb, line 43
def self.get_teams
  r = self.get_team_stats
  # CHECK IF THE RESPONSE FAILED, IF SO RETURN THE FAILURE
  if r.is_a? Numeric
    r
  else
    teams_hash = {}
    teams = r["resultSets"].first["rowSet"]
    teams.each_with_index do |val, index|
      teams_hash[teams[index][0]] = teams[index][1]
    end
    teams_hash
  end
end