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