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