Module: SportsDataApi::Nba
- 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
- DIR =
File.join(File.dirname(__FILE__), 'nba')
- BASE_URL =
'http://api.sportsdatallc.org/nba-%{access_level}%{version}'- DEFAULT_VERSION =
3- SPORT =
:nba
Class Method Summary collapse
-
.daily(year, month, day, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA daily schedule for a given date.
-
.game_summary(game, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA game summary for a given game.
-
.schedule(year, season, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA season schedule for a given year and season.
-
.team_roster(team, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA team roster.
-
.teams(version = DEFAULT_VERSION) ⇒ Object
Fetches all NBA teams.
Class Method Details
.daily(year, month, day, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA daily schedule for a given date
58 59 60 61 62 |
# File 'lib/sports_data_api/nba.rb', line 58 def self.daily(year, month, day, version = DEFAULT_VERSION) response = self.response_xml(version, "/games/#{year}/#{month}/#{day}/schedule.xml") return Games.new(response.xpath('league/daily-schedule')) end |
.game_summary(game, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA game summary for a given game
42 43 44 45 46 |
# File 'lib/sports_data_api/nba.rb', line 42 def self.game_summary(game, version = DEFAULT_VERSION) response = self.response_xml(version, "/games/#{game}/summary.xml") return Game.new(xml: response.xpath("/game")) end |
.schedule(year, season, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA season schedule for a given year and season
23 24 25 26 27 28 29 30 |
# File 'lib/sports_data_api/nba.rb', line 23 def self.schedule(year, season, version = DEFAULT_VERSION) season = season.to_s.upcase.to_sym raise SportsDataApi::Nba::Exception.new("#{season} is not a valid season") unless Season.valid?(season) response = self.response_xml(version, "/games/#{year}/#{season}/schedule.xml") return Season.new(response.xpath("/league/season-schedule")) end |
.team_roster(team, version = DEFAULT_VERSION) ⇒ Object
Fetches NBA team roster
34 35 36 37 38 |
# File 'lib/sports_data_api/nba.rb', line 34 def self.team_roster(team, version = DEFAULT_VERSION) response = self.response_xml(version, "/teams/#{team}/profile.xml") return Team.new(response.xpath("team")) end |
.teams(version = DEFAULT_VERSION) ⇒ Object
Fetches all NBA teams
50 51 52 53 54 |
# File 'lib/sports_data_api/nba.rb', line 50 def self.teams(version = DEFAULT_VERSION) response = self.response_xml(version, "/league/hierarchy.xml") return Teams.new(response.xpath('/league')) end |