Class: Sportradar::Nfl::Parsers::PlayByPlayParser
- Inherits:
-
Object
- Object
- Sportradar::Nfl::Parsers::PlayByPlayParser
- Defined in:
- lib/sportradar/nfl/parsers/play_by_play_parser.rb
Instance Method Summary collapse
- #away ⇒ Object
- #away_team_id ⇒ Object
- #drives ⇒ Object
- #events ⇒ Object
- #game_id ⇒ Object
- #has_quarters? ⇒ Boolean
- #home ⇒ Object
-
#initialize(game_play_by_play: {}) ⇒ PlayByPlayParser
constructor
A new instance of PlayByPlayParser.
- #plays ⇒ Object
- #quarters ⇒ Object
Constructor Details
#initialize(game_play_by_play: {}) ⇒ PlayByPlayParser
Returns a new instance of PlayByPlayParser.
5 6 7 |
# 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 |
Instance Method Details
#away ⇒ Object
13 14 15 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 13 def away game_play_by_play['away_team'] || {} end |
#away_team_id ⇒ Object
17 18 19 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 17 def away_team_id away['id'] end |
#drives ⇒ Object
33 34 35 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 33 def drives (quarters || []).map(&:drives).flatten end |
#events ⇒ Object
41 42 43 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 41 def events (drives || []).map(&:events) end |
#game_id ⇒ Object
9 10 11 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 9 def game_id game_play_by_play['id'] end |
#has_quarters? ⇒ Boolean
29 30 31 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 29 def has_quarters? quarters.count > 0 end |
#home ⇒ Object
21 22 23 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 21 def home game_play_by_play['home_team'] || {} end |
#plays ⇒ Object
37 38 39 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 37 def plays (drives || []).map(&:plays) end |
#quarters ⇒ Object
25 26 27 |
# File 'lib/sportradar/nfl/parsers/play_by_play_parser.rb', line 25 def quarters @quarters ||= build_quarters || [] end |