Class: Sportradar::Api::Football::Quarter

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/football/quarter.rb

Direct Known Subclasses

Ncaafb::Quarter, Nfl::Quarter

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#apiObject

Returns the value of attribute api.



5
6
7
# File 'lib/sportradar/api/football/quarter.rb', line 5

def api
  @api
end

#away_pointsObject

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_pointsObject

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

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/football/quarter.rb', line 5

def id
  @id
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/sportradar/api/football/quarter.rb', line 5

def number
  @number
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/football/quarter.rb', line 5

def response
  @response
end

#scoringObject

Returns the value of attribute scoring.



5
6
7
# File 'lib/sportradar/api/football/quarter.rb', line 5

def scoring
  @scoring
end

#sequenceObject

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_classObject



42
43
44
# File 'lib/sportradar/api/football/quarter.rb', line 42

def drive_class
  Drive
end

#drivesObject



38
39
40
# File 'lib/sportradar/api/football/quarter.rb', line 38

def drives
  @drives_hash.values
end

#overtime?Boolean

Returns:

  • (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