Class: Sportradar::Nfl::Models::Drive
- Inherits:
-
Object
- Object
- Sportradar::Nfl::Models::Drive
- Defined in:
- lib/sportradar/nfl/models/drive.rb
Overview
NOTE: This data structure isn’t techincially a single drive as due to the way Sportradar structures the play by play data and how it will be parsed a drive could be separated into two sets of info and plays by a TV timeout or the end of the quarter. The data/drive will continue using the same drive id in subsequent action data.
Therefore, it would be incorrect to count the number of plays in the drive to get the play count.
In addition, the drive data can contain actions/plays for other teams, such as when one team kicks off, then a tvtimeout, then the offensive team has their first play.
To get the offensive plays, you need to compare the drive’s team with the play’s side.
Instance Method Summary collapse
- #actions ⇒ Object
- #clock ⇒ Object
- #events ⇒ Object
- #game_id ⇒ Object
- #id ⇒ Object
-
#initialize(quarter:, attributes:) ⇒ Drive
constructor
A new instance of Drive.
- #plays ⇒ Object
- #quarter ⇒ Object
- #quarter_number ⇒ Object
- #team ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(quarter:, attributes:) ⇒ Drive
Returns a new instance of Drive.
20 21 22 23 |
# File 'lib/sportradar/nfl/models/drive.rb', line 20 def initialize(quarter:, attributes:) @quarter = quarter @attributes = attributes end |
Instance Method Details
#actions ⇒ Object
57 58 59 |
# File 'lib/sportradar/nfl/models/drive.rb', line 57 def actions @actions ||= @attributes.dig('actions') || [] end |
#clock ⇒ Object
41 42 43 |
# File 'lib/sportradar/nfl/models/drive.rb', line 41 def clock @attributes['clock'] || '0' end |
#events ⇒ Object
65 66 67 |
# File 'lib/sportradar/nfl/models/drive.rb', line 65 def events @events || build_events || [] end |
#game_id ⇒ Object
29 30 31 |
# File 'lib/sportradar/nfl/models/drive.rb', line 29 def game_id quarter.game_id end |
#id ⇒ Object
45 46 47 |
# File 'lib/sportradar/nfl/models/drive.rb', line 45 def id @attributes['id'] end |
#plays ⇒ Object
61 62 63 |
# File 'lib/sportradar/nfl/models/drive.rb', line 61 def plays @plays || build_plays || [] end |
#quarter ⇒ Object
33 34 35 |
# File 'lib/sportradar/nfl/models/drive.rb', line 33 def quarter @quarter end |
#quarter_number ⇒ Object
37 38 39 |
# File 'lib/sportradar/nfl/models/drive.rb', line 37 def quarter_number @quarter.number end |
#team ⇒ Object
49 50 51 |
# File 'lib/sportradar/nfl/models/drive.rb', line 49 def team @attributes['team'] end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/sportradar/nfl/models/drive.rb', line 25 def to_s "#{quarter.to_s} #{clock}" end |
#type ⇒ Object
53 54 55 |
# File 'lib/sportradar/nfl/models/drive.rb', line 53 def type @attributes['type'] end |