Module: SportsDataApi::Nfl

Defined in:
lib/sports_data_api/nfl.rb,
lib/sports_data_api/nfl/game.rb,
lib/sports_data_api/nfl/team.rb,
lib/sports_data_api/nfl/week.rb,
lib/sports_data_api/nfl/games.rb,
lib/sports_data_api/nfl/teams.rb,
lib/sports_data_api/nfl/venue.rb,
lib/sports_data_api/nfl/player.rb,
lib/sports_data_api/nfl/season.rb,
lib/sports_data_api/nfl/weather.rb,
lib/sports_data_api/nfl/injuries.rb,
lib/sports_data_api/nfl/broadcast.rb,
lib/sports_data_api/nfl/team_roster.rb,
lib/sports_data_api/nfl/team_season_stats.rb,
lib/sports_data_api/nfl/player_season_stats.rb

Defined Under Namespace

Classes: Broadcast, Exception, Game, Games, Injuries, Player, PlayerSeasonStats, Season, Team, TeamRoster, TeamSeasonStats, Teams, Venue, Weather, Week

Constant Summary collapse

DIR =
File.join(File.dirname(__FILE__), 'nfl')
BASE_URL =
'http://api.sportsdatallc.org/nfl-%{access_level}%{version}'
DEFAULT_VERSION =
1
SPORT =
:nfl

Class Method Summary collapse

Class Method Details

.boxscore(year, season, week, home, away, version = DEFAULT_VERSION) ⇒ Object

Fetches NFL boxscore for a given game



63
64
65
66
67
68
69
70
# File 'lib/sports_data_api/nfl.rb', line 63

def self.boxscore(year, season, week, home, away, version = DEFAULT_VERSION)
  season = season.to_s.upcase.to_sym
  raise SportsDataApi::Nfl::Exception.new("#{season} is not a valid season") unless Season.valid?(season)

  response = self.response_json(version, "/#{year}/#{season}/#{week}/#{away}/#{home}/boxscore.json")

  return Game.new(year, season, week, response)
end

.game_statistics(year, season, week, home, away, version = DEFAULT_VERSION) ⇒ Object

Fetches statistics for a given NFL game



74
75
76
77
78
79
80
81
# File 'lib/sports_data_api/nfl.rb', line 74

def self.game_statistics(year, season, week, home, away, version = DEFAULT_VERSION)
  season = season.to_s.upcase.to_sym
  raise SportsDataApi::Nfl::Exception.new("#{season} is not a valid season") unless Season.valid?(season)

  response = self.response_json(version, "/#{year}/#{season}/#{week}/#{away}/#{home}/statistics.json")

  return Game.new(year, season, week, response)
end

.player_season_stats(team, season, season_type, version = DEFAULT_VERSION) ⇒ Object

Fetch NFL player seaon stats for a given team, season and season type



55
56
57
58
59
# File 'lib/sports_data_api/nfl.rb', line 55

def self.player_season_stats(team, season, season_type, version = DEFAULT_VERSION)
  response = self.response_json(version, "/teams/#{team}/#{season}/#{season_type}/statistics.json")

  return PlayerSeasonStats.new(response)
end

.schedule(year, season, version = DEFAULT_VERSION) ⇒ Object

Fetches NFL season schedule for a given year and season



28
29
30
31
32
33
34
35
# File 'lib/sports_data_api/nfl.rb', line 28

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

  response = self.response_json(version, "/#{year}/#{season}/schedule.json")

  return Season.new(response)
end

.team_roster(team, version = DEFAULT_VERSION) ⇒ Object

Fetch NFL team roster



39
40
41
42
43
# File 'lib/sports_data_api/nfl.rb', line 39

def self.team_roster(team, version = DEFAULT_VERSION)
  response = self.response_json(version, "/teams/#{team}/roster.json")

  return TeamRoster.new(response)
end

.team_season_stats(team, season, season_type, version = DEFAULT_VERSION) ⇒ Object

Fetch NFL team seaon stats for a given team, season and season type



47
48
49
50
51
# File 'lib/sports_data_api/nfl.rb', line 47

def self.team_season_stats(team, season, season_type, version = DEFAULT_VERSION)
  response = self.response_json(version, "/teams/#{team}/#{season}/#{season_type}/statistics.json")

  return TeamSeasonStats.new(response)
end

.teams(version = DEFAULT_VERSION) ⇒ Object

Fetches all NFL teams



85
86
87
88
89
# File 'lib/sports_data_api/nfl.rb', line 85

def self.teams(version = DEFAULT_VERSION)
  response = self.response_json(version, "/teams/hierarchy.json")

  return Teams.new(response)
end

.weekly(year, season, week, version = DEFAULT_VERSION) ⇒ Object

Fetches NFL weekly schedule for a given year, season and week



93
94
95
96
97
98
99
100
# File 'lib/sports_data_api/nfl.rb', line 93

def self.weekly(year, season, week, version = DEFAULT_VERSION)
  season = season.to_s.upcase.to_sym
  raise SportsDataApi::Nfl::Exception.new("#{season} is not a valid season") unless Season.valid?(season)

  response = self.response_json(version, "/#{year}/#{season}/#{week}/schedule.json")

  return Games.new(year, season, week, response)
end