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/league.rb,
lib/sports_data_api/mlb/player.rb,
lib/sports_data_api/mlb/division.rb,
lib/sports_data_api/mlb/statistics.rb,
lib/sports_data_api/mlb/merged_stats.rb
Defined Under Namespace
Classes: Division, Exception, Game, League, MergedStats, Player, Statistics, Team
Constant Summary collapse
- API_VERSION =
6- BASE_URL =
'https://api.sportradar.us/mlb-%{access_level}%{version}'- DIR =
File.join(File.dirname(__FILE__), 'mlb')
- SPORT =
:mlb
Class Method Summary collapse
-
.daily_schedule(year, month, day) ⇒ Object
Fetches MLB daily schedule for a given date.
-
.daily_summary(year, month, day) ⇒ Object
Fetches MLB daily summary.
-
.game(game_id) ⇒ Object
Fetches MLB game summary.
-
.leagues ⇒ Object
Fetches all MLB leagues.
-
.season_schedule(year, season) ⇒ Object
Fetches MLB season schedule for a given year and season.
-
.team(team_id) ⇒ Object
Fetches MLB team roster.
Methods included from Request
response_json, response_xml, response_xml_xpath
Class Method Details
.daily_schedule(year, month, day) ⇒ Object
Fetches MLB daily schedule for a given date
38 39 40 41 |
# File 'lib/sports_data_api/mlb.rb', line 38 def daily_schedule(year, month, day) response = response_json("/games/#{year}/#{month}/#{day}/schedule.json") map_model response, 'games', Game end |
.daily_summary(year, month, day) ⇒ Object
Fetches MLB daily summary
45 46 47 48 |
# File 'lib/sports_data_api/mlb.rb', line 45 def daily_summary(year, month, day) response = response_json("/games/#{year}/#{month}/#{day}/summary.json") map_model response['league'], 'games', Game end |
.game(game_id) ⇒ Object
Fetches MLB game summary
52 53 54 55 |
# File 'lib/sports_data_api/mlb.rb', line 52 def game(game_id) response = response_json("/games/#{game_id}/summary.json") Game.new(response['game']) end |
.leagues ⇒ Object
Fetches all MLB leagues
24 25 26 27 |
# File 'lib/sports_data_api/mlb.rb', line 24 def leagues response = response_json('/league/hierarchy.json') map_model response, 'leagues', League end |
.season_schedule(year, season) ⇒ Object
Fetches MLB season schedule for a given year and season
31 32 33 34 |
# File 'lib/sports_data_api/mlb.rb', line 31 def season_schedule(year, season) response = response_json("/games/#{year}/#{season}/schedule.json") map_model response, 'games', Game end |
.team(team_id) ⇒ Object
Fetches MLB team roster
59 60 61 |
# File 'lib/sports_data_api/mlb.rb', line 59 def team(team_id) Team.new(response_json("/teams/#{team_id}/profile.json")) end |