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
Defined Under Namespace
Classes: Division, Game, League, 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
41 42 43 44 |
# File 'lib/sports_data_api/mlb.rb', line 41 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
48 49 50 51 |
# File 'lib/sports_data_api/mlb.rb', line 48 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
55 56 57 58 |
# File 'lib/sports_data_api/mlb.rb', line 55 def game(game_id) response = response_json("/games/#{game_id}/summary.json") Game.new(response['game']) end |
.leagues ⇒ Object
Fetches leagues hierachy
21 22 23 24 |
# File 'lib/sports_data_api/mlb.rb', line 21 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
34 35 36 37 |
# File 'lib/sports_data_api/mlb.rb', line 34 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
62 63 64 |
# File 'lib/sports_data_api/mlb.rb', line 62 def team(team_id) Team.new(response_json("/teams/#{team_id}/profile.json")) end |
.teams ⇒ Object
Fetches all MLB teams
28 29 30 |
# File 'lib/sports_data_api/mlb.rb', line 28 def teams leagues.flat_map(&:teams) end |