Class: Sportradar::Api::Football::Quarter
- Defined in:
- lib/sportradar/api/football/quarter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#away_points ⇒ Object
Returns the value of attribute away_points.
-
#home_points ⇒ Object
Returns the value of attribute home_points.
-
#id ⇒ Object
Returns the value of attribute id.
-
#number ⇒ Object
Returns the value of attribute number.
-
#response ⇒ Object
Returns the value of attribute response.
-
#scoring ⇒ Object
Returns the value of attribute scoring.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
Instance Method Summary collapse
- #drive_class ⇒ Object
- #drives ⇒ Object
-
#initialize(data, **opts) ⇒ Quarter
constructor
A new instance of Quarter.
- #overtime? ⇒ Boolean
- #update(data, **opts) ⇒ Object
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
#initialize(data, **opts) ⇒ Quarter
Returns a new instance of Quarter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sportradar/api/football/quarter.rb', line 7 def initialize(data, **opts) @response = data @id = data[self.class.period_index] @api = opts[:api] @drives_hash = {} update(data, **opts) end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def api @api end |
#away_points ⇒ Object
Returns the value of attribute away_points.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def away_points @away_points end |
#home_points ⇒ Object
Returns the value of attribute home_points.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def home_points @home_points end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def id @id end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def number @number end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def response @response end |
#scoring ⇒ Object
Returns the value of attribute scoring.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def scoring @scoring end |
#sequence ⇒ Object
Returns the value of attribute sequence.
5 6 7 |
# File 'lib/sportradar/api/football/quarter.rb', line 5 def sequence @sequence end |
Instance Method Details
#drive_class ⇒ Object
42 43 44 |
# File 'lib/sportradar/api/football/quarter.rb', line 42 def drive_class Drive end |
#drives ⇒ Object
38 39 40 |
# File 'lib/sportradar/api/football/quarter.rb', line 38 def drives @drives_hash.values end |
#overtime? ⇒ Boolean
34 35 36 |
# File 'lib/sportradar/api/football/quarter.rb', line 34 def overtime? (@sequence || @number) > 4 end |
#update(data, **opts) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sportradar/api/football/quarter.rb', line 17 def update(data, **opts) @number = data["number"] @sequence = data["sequence"] @home_points = data["home_points"] @away_points = data["away_points"] @home_info = data["home"] @away_info = data["away"] if data['pbp'] opts[:game].update_drives(data['pbp'], quarter: self) create_data(@drives_hash, data['pbp'], klass: drive_class, api: api, quarter: self) end self end |