Class: MLB::PlayByPlay
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::PlayByPlay
- Defined in:
- lib/mlb/play_by_play.rb
Overview
Provides methods for fetching play-by-play data from the API
Instance Attribute Summary collapse
-
#all_plays ⇒ Array<Play>
Returns all plays in the game.
-
#current_play ⇒ Play
Returns the current play.
-
#scoring_plays ⇒ Array<Integer>
Returns indices of scoring plays.
Class Method Summary collapse
-
.find(game:) ⇒ PlayByPlay
Retrieves play-by-play data for a game.
Instance Attribute Details
#all_plays ⇒ Array<Play>
Returns all plays in the game
13 |
# File 'lib/mlb/play_by_play.rb', line 13 attribute :all_plays, Play, collection: true |
#current_play ⇒ Play
Returns the current play
21 |
# File 'lib/mlb/play_by_play.rb', line 21 attribute :current_play, Play |
#scoring_plays ⇒ Array<Integer>
Returns indices of scoring plays
29 |
# File 'lib/mlb/play_by_play.rb', line 29 attribute :scoring_plays, Shale::Type::Integer, collection: true |
Class Method Details
.find(game:) ⇒ PlayByPlay
Retrieves play-by-play data for a game
46 47 48 49 50 |
# File 'lib/mlb/play_by_play.rb', line 46 def self.find(game:) game_pk = game.respond_to?(:game_pk) ? game.game_pk : game response = CLIENT.get("game/#{game_pk}/playByPlay") from_json(response) end |