Module: SportsDataApi::Ncaamb

Defined in:
lib/sports_data_api/ncaamb.rb,
lib/sports_data_api/ncaamb/game.rb,
lib/sports_data_api/ncaamb/team.rb,
lib/sports_data_api/ncaamb/games.rb,
lib/sports_data_api/ncaamb/teams.rb,
lib/sports_data_api/ncaamb/venue.rb,
lib/sports_data_api/ncaamb/player.rb,
lib/sports_data_api/ncaamb/season.rb,
lib/sports_data_api/ncaamb/broadcast.rb,
lib/sports_data_api/ncaamb/tournament.rb,
lib/sports_data_api/ncaamb/tournament_game.rb,
lib/sports_data_api/ncaamb/tournament_list.rb,
lib/sports_data_api/ncaamb/tournament_schedule.rb

Defined Under Namespace

Classes: Broadcast, Exception, Game, Games, Player, Season, Team, Teams, Tournament, TournamentGame, TournamentList, TournamentSchedule, Venue

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.daily(year, month, day, version = DEFAULT_VERSION) ⇒ Object

## # Fetches NCAAMB daily schedule for a given date



62
63
64
65
66
# File 'lib/sports_data_api/ncaamb.rb', line 62

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 NCAAMB game summary for a given game



46
47
48
49
50
# File 'lib/sports_data_api/ncaamb.rb', line 46

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 NCAAAMB season schedule for a given year and season



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

def self.schedule(year, season, version = DEFAULT_VERSION)
  season = season.to_s.upcase.to_sym
  raise SportsDataApi::Ncaamb::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 NCAAMB team roster



38
39
40
41
42
# File 'lib/sports_data_api/ncaamb.rb', line 38

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 NCAAMB teams



54
55
56
57
58
# File 'lib/sports_data_api/ncaamb.rb', line 54

def self.teams(version = DEFAULT_VERSION)
  response = self.response_xml(version, "/league/hierarchy.xml")

  return Teams.new(response.xpath('/league'))
end

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

Fetches NCAAAMB tournaments for a given year and season



69
70
71
72
73
74
75
76
# File 'lib/sports_data_api/ncaamb.rb', line 69

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

  response = self.response_xml(version, "/tournaments/#{year}/#{season}/schedule.xml")

  return TournamentList.new(response.xpath("/league/season-schedule"))
end

.tournament_schedule(year, season, tournament_id, version = DEFAULT_VERSION) ⇒ Object



78
79
80
81
82
83
# File 'lib/sports_data_api/ncaamb.rb', line 78

def self.tournament_schedule(year, season, tournament_id, version = DEFAULT_VERSION)
  response = self.response_xml(version, "/tournaments/#{tournament_id}/schedule.xml")
  raise SportsDataApi::Ncaamb::Exception.new("#{season} is not a valid season") unless TournamentSchedule.valid?(season)

  return TournamentSchedule.new(year, season, response.xpath("/league/tournament-schedule"))
end