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/scoring.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, Scoring, 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 leagues hierachy.
-
.season_schedule(year, season) ⇒ Object
Fetches MLB season schedule for a given year and season.
-
.team(team_id) ⇒ Object
Fetches MLB team roster.
-
.teams ⇒ Object
Fetches all MLB teams.
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
45 46 47 48 |
# File 'lib/sports_data_api/mlb.rb', line 45 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
52 53 54 55 |
# File 'lib/sports_data_api/mlb.rb', line 52 def daily_summary(year, month, day) response = response_json("/games/#{year}/#{month}/#{day}/summary.json") map_model response['league'], 'games', Game, 'game' end |
.game(game_id) ⇒ Object
Fetches MLB game summary
59 60 61 62 |
# File 'lib/sports_data_api/mlb.rb', line 59 def game(game_id) response = response_json("/games/#{game_id}/summary.json") Game.new(response['game']) end |
.leagues ⇒ Object
Fetches leagues hierachy
25 26 27 28 |
# File 'lib/sports_data_api/mlb.rb', line 25 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
38 39 40 41 |
# File 'lib/sports_data_api/mlb.rb', line 38 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
66 67 68 |
# File 'lib/sports_data_api/mlb.rb', line 66 def team(team_id) Team.new(response_json("/teams/#{team_id}/profile.json")) end |
.teams ⇒ Object
Fetches all MLB teams
32 33 34 |
# File 'lib/sports_data_api/mlb.rb', line 32 def teams leagues.flat_map(&:teams) end |