Class: Sportradar::Api::Football::Nfl::Drive
- Defined in:
- lib/sportradar/api/football/nfl/drive.rb
Instance Attribute Summary
Attributes inherited from Drive
#api, #duration, #end_reason, #first_downs, #gain, #id, #penalty_yards, #play_count, #quarter, #response, #scoring_drive, #sequence, #start_reason, #team
Instance Method Summary collapse
Methods inherited from Drive
#end_reason_possibilities, #events, #halftime?, #initialize, new, #normalized_end_reason, #over?, #overtime?, #plays, #update
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
This class inherits a constructor from Sportradar::Api::Football::Drive
Instance Method Details
#handle_plays_and_events(data, **opts) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/sportradar/api/football/nfl/drive.rb', line 7 def handle_plays_and_events(data, **opts) things = (Array(data['events']) + Array(data['actions'])).group_by { |hash| hash['type'] } create_data(@plays_hash, things['play'], klass: Play, api: api, drive: self) if things['play'] create_data(@events_hash, things['event'], klass: Event, api: api, drive: self) if things['setup'] create_data(@events_hash, things['event'], klass: Event, api: api, drive: self) if things['event'] end |
#team_id ⇒ Object
15 16 17 |
# File 'lib/sportradar/api/football/nfl/drive.rb', line 15 def team_id plays.last&.start_situation&.team_id end |