class Sportradar::Nfl::Parsers::PlayByPlayParser
Attributes
game_play_by_play[R]
Public Class Methods
new(game_play_by_play: {})
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 5 def initialize(game_play_by_play: {}) @game_play_by_play = game_play_by_play['game'] || game_play_by_play end
Public Instance Methods
away()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 13 def away game_play_by_play['away_team'] || {} end
away_team_id()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 17 def away_team_id away['id'] end
drives()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 33 def drives (quarters || []).map(&:drives).flatten end
events()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 41 def events (drives || []).map(&:events) end
game_id()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 9 def game_id game_play_by_play['id'] end
has_quarters?()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 29 def has_quarters? quarters.count > 0 end
home()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 21 def home game_play_by_play['home_team'] || {} end
plays()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 37 def plays (drives || []).map(&:plays) end
quarters()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 25 def quarters @quarters ||= build_quarters || [] end
Private Instance Methods
build_quarters()
click to toggle source
# File lib/sportradar/nfl/parsers/play_by_play_parser.rb, line 49 def build_quarters game_play_by_play. dig('quarters'). map { |attributes| Models::Quarter.new(game_id: game_id, attributes: attributes) } end