Module: SportsDataApi::Mlb
- Extended by:
- Request
- 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
- API_VERSION =
4- BASE_URL =
'https://api.sportsdatallc.org/mlb-%{access_level}%{version}'- DIR =
File.join(File.dirname(__FILE__), 'mlb')
- SPORT =
:mlb
Class Method Summary collapse
-
.daily(year, month, day) ⇒ Object
Fetches MLB daily schedule for a given date.
-
.game_boxscore(event_id) ⇒ Object
Fetch MLB Game Boxscore.
-
.game_statistics(event_id) ⇒ Object
Fetch MLB game stats.
-
.schedule(year = Date.today.year) ⇒ Object
Fetches MLB season schedule for a given year and season.
-
.team_roster(year = Date.today.year) ⇒ Object
Fetches MLB team roster.
-
.teams(year = Date.today.year) ⇒ Object
Fetches all NBA teams.
-
.venues ⇒ Object
Fetches MLB venues.
Methods included from Request
response_json, response_xml, response_xml_xpath
Class Method Details
.daily(year, month, day) ⇒ Object
Fetches MLB daily schedule for a given date
42 43 44 |
# File 'lib/sports_data_api/mlb.rb', line 42 def daily(year, month, day) Games.new(response_xml_xpath("/daily/schedule/#{year}/#{month}/#{day}.xml", 'calendars')) end |
.game_boxscore(event_id) ⇒ Object
Fetch MLB Game Boxscore
60 61 62 |
# File 'lib/sports_data_api/mlb.rb', line 60 def game_boxscore(event_id) Boxscore.new(response_xml_xpath("/boxscore/#{event_id}.xml", '/boxscore')) end |
.game_statistics(event_id) ⇒ Object
Fetch MLB game stats
54 55 56 |
# File 'lib/sports_data_api/mlb.rb', line 54 def game_statistics(event_id) GameStats.new(response_xml_xpath("/statistics/#{event_id}.xml", '/statistics')) end |
.schedule(year = Date.today.year) ⇒ Object
Fetches MLB season schedule for a given year and season
36 37 38 |
# File 'lib/sports_data_api/mlb.rb', line 36 def schedule(year = Date.today.year) Season.new(response_xml_xpath("/schedule/#{year}.xml", 'calendars')) end |
.team_roster(year = Date.today.year) ⇒ Object
Fetches MLB team roster
66 67 68 |
# File 'lib/sports_data_api/mlb.rb', line 66 def team_roster(year=Date.today.year) Players.new(response_xml_xpath("/rosters-full/#{year}.xml", 'rosters')) end |
.teams(year = Date.today.year) ⇒ Object
Fetches all NBA teams
30 31 32 |
# File 'lib/sports_data_api/mlb.rb', line 30 def teams(year = Date.today.year) Teams.new(response_xml_xpath("/teams/#{year}.xml", '/teams')) end |
.venues ⇒ Object
Fetches MLB venues
48 49 50 |
# File 'lib/sports_data_api/mlb.rb', line 48 def venues Venues.new(response_xml_xpath('/venues/venues.xml', 'venues')) end |