Module: SportsDataApi::Nba

Extended by:
Request
Defined in:
lib/sports_data_api/nba.rb,
lib/sports_data_api/nba/game.rb,
lib/sports_data_api/nba/team.rb,
lib/sports_data_api/nba/games.rb,
lib/sports_data_api/nba/teams.rb,
lib/sports_data_api/nba/venue.rb,
lib/sports_data_api/nba/player.rb,
lib/sports_data_api/nba/season.rb,
lib/sports_data_api/nba/broadcast.rb

Defined Under Namespace

Classes: Broadcast, Exception, Game, Games, Player, Season, Team, Teams, Venue

Constant Summary collapse

API_VERSION =
3
BASE_URL =
'https://api.sportsdatallc.org/nba-%{access_level}%{version}'
DIR =
File.join(File.dirname(__FILE__), 'nba')
SPORT =
:nba

Class Method Summary collapse

Methods included from Request

response_json, response_xml, response_xml_xpath

Class Method Details

.daily(year, month, day) ⇒ Object

Fetches NBA daily schedule for a given date



52
53
54
# File 'lib/sports_data_api/nba.rb', line 52

def daily(year, month, day)
  Games.new(response_xml_xpath("/games/#{year}/#{month}/#{day}/schedule.xml", 'league/daily-schedule'))
end

.game_summary(game) ⇒ Object

Fetches NBA game summary for a given game



40
41
42
# File 'lib/sports_data_api/nba.rb', line 40

def game_summary(game)
  Game.new(xml: response_xml_xpath("/games/#{game}/summary.xml", '/game'))
end

.schedule(year, season) ⇒ Object

Fetches NBA season schedule for a given year and season

Raises:



25
26
27
28
29
30
# File 'lib/sports_data_api/nba.rb', line 25

def schedule(year, season)
  season = season.to_s.upcase.to_sym
  raise Exception.new("#{season} is not a valid season") unless Season.valid?(season)

  Season.new(response_xml_xpath("/games/#{year}/#{season}/schedule.xml", "/league/season-schedule"))
end

.team_roster(team) ⇒ Object

Fetches NBA team roster



34
35
36
# File 'lib/sports_data_api/nba.rb', line 34

def team_roster(team)
  Team.new(response_xml_xpath("/teams/#{team}/profile.xml", 'team'))
end

.teamsObject

Fetches all NBA teams



46
47
48
# File 'lib/sports_data_api/nba.rb', line 46

def teams
  Teams.new(response_xml_xpath('/league/hierarchy.xml', '/league'))
end