Module: MLBStatsAPI::Games
- Included in:
- Client
- Defined in:
- lib/mlb_stats_api/games.rb
Constant Summary collapse
- PREGAME_STATUSES =
/Preview|Warmup|Pre-Game|Delayed Start|Scheduled/- POSTGAME_STATUSES =
/Final|Game Over|Postponed|Completed Early/
Class Method Summary collapse
Instance Method Summary collapse
- #boxscore(game_pk) ⇒ Object
- #color_feed(game_pk, timecode: nil) ⇒ Object
- #content(game_pk, limit: nil) ⇒ Object
- #context_metrics(game_pk, timecode: nil) ⇒ Object
-
#linescore(game_pk) ⇒ Object
def color_feed_timestamps(game_pk) get “/game/#game_pk/feed/color/timestamps” end.
-
#live_feed(game_pk, timecode: nil) ⇒ Object
This endpoint can return very large payloads.
- #live_feed_diff(game_pk, timecode: nil, snapshot_at: nil) ⇒ Object
- #live_feed_timestamps(game_pk) ⇒ Object
- #play_by_play(game_pk, timecode: nil) ⇒ Object
- #win_probability(game_pk, timecode: nil) ⇒ Object
Class Method Details
.postgame_status?(status) ⇒ Boolean
10 |
# File 'lib/mlb_stats_api/games.rb', line 10 def self.postgame_status?(status) = POSTGAME_STATUSES.match?(status) |
.pregame_status?(status) ⇒ Boolean
8 |
# File 'lib/mlb_stats_api/games.rb', line 8 def self.pregame_status?(status) = PREGAME_STATUSES.match?(status) |
Instance Method Details
#boxscore(game_pk) ⇒ Object
12 |
# File 'lib/mlb_stats_api/games.rb', line 12 def boxscore(game_pk) = get("/game/#{game_pk}/boxscore") |
#color_feed(game_pk, timecode: nil) ⇒ Object
40 41 42 |
# File 'lib/mlb_stats_api/games.rb', line 40 def color_feed(game_pk, timecode: nil) MLBStatsAPI::ColorFeed.new self, game_pk, get("/game/#{game_pk}/feed/color", timecode:) end |
#content(game_pk, limit: nil) ⇒ Object
14 |
# File 'lib/mlb_stats_api/games.rb', line 14 def content(game_pk, limit: nil) = get("/game/#{game_pk}/content", highlightLimit: limit) |
#context_metrics(game_pk, timecode: nil) ⇒ Object
16 |
# File 'lib/mlb_stats_api/games.rb', line 16 def context_metrics(game_pk, timecode: nil) = get("/game/#{game_pk}/contextMetrics", timecode:) |
#linescore(game_pk) ⇒ Object
def color_feed_timestamps(game_pk)
get "/game/#{game_pk}/feed/color/timestamps"
end
62 |
# File 'lib/mlb_stats_api/games.rb', line 62 def linescore(game_pk) = get("/game/#{game_pk}/linescore") |
#live_feed(game_pk, timecode: nil) ⇒ Object
This endpoint can return very large payloads. It is STRONGLY recommended that clients ask for diffs and use “Accept-Encoding: gzip” header.
20 21 22 |
# File 'lib/mlb_stats_api/games.rb', line 20 def live_feed(game_pk, timecode: nil) MLBStatsAPI::LiveFeed.new self, get("/game/#{game_pk}/feed/live", version: '1.1', timecode:) end |
#live_feed_diff(game_pk, timecode: nil, snapshot_at: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mlb_stats_api/games.rb', line 24 def live_feed_diff(game_pk, timecode: nil, snapshot_at: nil) query = { version: '1.1' } if timecode query[:startTimecode] = timecode elsif snapshot_at query[:endTimecode] = snapshot_at else raise ArgumentError, 'Please pass either a timecode or a snapshot.' end get "/game/#{game_pk}/feed/live/diffPatch", query end |
#live_feed_timestamps(game_pk) ⇒ Object
38 |
# File 'lib/mlb_stats_api/games.rb', line 38 def (game_pk) = get("/game/#{game_pk}/feed/live/timestamps", version: '1.1') |
#play_by_play(game_pk, timecode: nil) ⇒ Object
64 |
# File 'lib/mlb_stats_api/games.rb', line 64 def play_by_play(game_pk, timecode: nil) = get("/game/#{game_pk}/playByPlay", timecode:) |
#win_probability(game_pk, timecode: nil) ⇒ Object
66 |
# File 'lib/mlb_stats_api/games.rb', line 66 def win_probability(game_pk, timecode: nil) = get("/game/#{game_pk}/winProbability", timecode:) |