class Sportradar::Mlb::Parsers::ScoringPlaysParser
Attributes
game_boxscore[R]
Public Class Methods
new(game_boxscore: {})
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 5 def initialize(game_boxscore: {}) @game_boxscore = game_boxscore['game'] || game_boxscore end
Public Instance Methods
all()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 55 def all away_team_plays + home_team_plays end
away()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 13 def away game_boxscore['away'] || {} end
away_events()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 29 def away_events away['events'] || [] end
away_team_hitter_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 59 def away_team_hitter_ids away_team_plays.map(&:hitter_id). uniq end
away_team_id()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 17 def away_team_id away['id'] end
away_team_pitcher_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 69 def away_team_pitcher_ids away_team_plays.map(&:pitcher_id). uniq end
away_team_plays()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 41 def away_team_plays away_events.map do |event| build_scoring_play(team_id: away_team_id, event: event) end end
away_team_runner_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 79 def away_team_runner_ids away_team_plays.map(&:runner_ids). flatten. uniq end
events()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 37 def events away_events + home_events end
first()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 105 def first all. first end
game_id()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 9 def game_id game_boxscore['id'] end
hitter_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 95 def hitter_ids all.map(&:hitter_id) end
home()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 21 def home game_boxscore['home'] || {} end
home_events()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 33 def home_events home['events'] || [] end
home_team_hitter_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 64 def home_team_hitter_ids home_team_plays.map(&:pitcher_id). uniq end
home_team_id()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 25 def home_team_id home['id'] end
home_team_pitcher_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 74 def home_team_pitcher_ids home_team_plays.map(&:pitcher_id). uniq end
home_team_plays()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 48 def home_team_plays home_events.map do |event| build_scoring_play(team_id: home_team_id, event: event) end end
home_team_runner_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 85 def home_team_runner_ids home_team_plays.map(&:runner_ids). flatten. uniq end
last()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 110 def last all. last end
pitcher_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 91 def pitcher_ids all.map(&:pitcher_id) end
runner_ids()
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 99 def runner_ids all.map(&:runner_ids). flatten. uniq end
Private Instance Methods
build_scoring_play(team_id:, event:)
click to toggle source
# File lib/sportradar/mlb/parsers/scoring_plays_parser.rb, line 119 def build_scoring_play(team_id:, event:) Sportradar::Mlb::Models::ScoringPlay.new(game_id: game_id, team_id: team_id, event: event) end