Module: SportsDataApi::Mlb

Defined in:
lib/sports_data_api/mlb.rb,
lib/sports_data_api/mlb/game.rb,
lib/sports_data_api/mlb/team.rb,
lib/sports_data_api/mlb/games.rb,
lib/sports_data_api/mlb/teams.rb,
lib/sports_data_api/mlb/venue.rb,
lib/sports_data_api/mlb/player.rb,
lib/sports_data_api/mlb/season.rb,
lib/sports_data_api/mlb/venues.rb,
lib/sports_data_api/mlb/players.rb,
lib/sports_data_api/mlb/boxscore.rb,
lib/sports_data_api/mlb/broadcast.rb,
lib/sports_data_api/mlb/game_stat.rb,
lib/sports_data_api/mlb/game_stats.rb

Defined Under Namespace

Classes: Boxscore, Broadcast, Exception, Game, GameStat, GameStats, Games, Player, Players, Season, Team, Teams, Venue, Venues

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

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

Fetches MLB daily schedule for a given date



42
43
44
45
# File 'lib/sports_data_api/mlb.rb', line 42

def self.daily(year, month, day, version = DEFAULT_VERSION)
  response = self.response_xml(version, "/daily/schedule/#{year}/#{month}/#{day}.xml")
  return Games.new(response.xpath("calendars"))
end

.game_boxscore(event_id, version = DEFAULT_VERSION) ⇒ Object

Fetch MLB Game Boxscore



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

def self.game_boxscore(event_id, version = DEFAULT_VERSION )
  response = self.response_xml(version, "/boxscore/#{event_id}.xml")
  return Boxscore.new(response.xpath("/boxscore"))
end

.game_statistics(event_id, version = DEFAULT_VERSION) ⇒ Object

Fetch MLB game stats



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

def self.game_statistics(event_id, version = DEFAULT_VERSION )
  response = self.response_xml(version, "/statistics/#{event_id}.xml")
  return GameStats.new(response.xpath("/statistics"))
end

.schedule(year = Date.today.year, version = DEFAULT_VERSION) ⇒ Object

Fetches MLB season schedule for a given year and season



35
36
37
38
# File 'lib/sports_data_api/mlb.rb', line 35

def self.schedule(year=Date.today.year, version = DEFAULT_VERSION)
  response = self.response_xml(version, "/schedule/#{year}.xml")
  return Season.new(response.xpath("calendars"))
end

.team_roster(year = Date.today.year, version = DEFAULT_VERSION) ⇒ Object

Fetches MLB team roster



70
71
72
73
# File 'lib/sports_data_api/mlb.rb', line 70

def self.team_roster(year=Date.today.year, version = DEFAULT_VERSION)
  response = self.response_xml(version, "/rosters-full/#{year}.xml")
  return Players.new(response.xpath("rosters"))
end

.teams(year = Date.today.year, version = DEFAULT_VERSION) ⇒ Object

Fetches all NBA teams



28
29
30
31
# File 'lib/sports_data_api/mlb.rb', line 28

def self.teams(year=Date.today.year, version = DEFAULT_VERSION)
  response = self.response_xml(version, "/teams/#{year}.xml")
  return Teams.new(response.xpath('/teams'))
end

.venues(version = DEFAULT_VERSION) ⇒ Object

Fetches MLB venues



49
50
51
52
# File 'lib/sports_data_api/mlb.rb', line 49

def self.venues(version = DEFAULT_VERSION)
  response = self.response_xml(version, "/venues/venues.xml")
  return Venues.new(response.xpath("venues"))
end