Module: SportsDataApi::Nhl

Extended by:
Request
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

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

Class Method Summary collapse

Methods included from Request

response_json, response_xml, response_xml_xpath

Class Method Details

.daily(year, month, day) ⇒ Object

Fetches NHL daily schedule for a given date



52
53
54
# File 'lib/sports_data_api/nhl.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 NHL game summary for a given game



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

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

.schedule(year, season) ⇒ Object

Fetches NHL season schedule for a given year and season

Raises:



25
26
27
28
29
30
# File 'lib/sports_data_api/nhl.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 NHL team roster



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

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

.teamsObject

Fetches all NHL teams



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

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