lib/sportradar/api/football/game.rb in sportradar-api-0.12.0 vs lib/sportradar/api/football/game.rb in sportradar-api-0.12.1
- old
+ new
@@ -157,12 +157,12 @@
end
def update_score(score)
@score.merge!(score)
end
- def update_drives(data)
- create_data(@drives_hash, data, klass: drive_class, api: api, game: self)
+ def update_drives(data, **opts)
+ create_data(@drives_hash, data, klass: drive_class, api: api, game: self, **opts)
end
def leading_team_id
return nil if tied?
score.max_by(&:last).first
@@ -171,11 +171,11 @@
def leading_team
@teams_hash[leading_team_id] || (@away_id == leading_team_id && away) || (@home_id == leading_team_id && home)
end
def current_possession_team_id
- drives.grep(Sportradar::Api::Football::Drive).last&.team_id
+ drives.last&.team_id
end
def next_possession_team_id
(@teams_hash.keys - [current_possession_team_id]).first || (@away_id == current_possession_team_id && @home_id) || (@home_id == current_possession_team_id && @away_id)
end
@@ -207,14 +207,19 @@
get_pbp
end
@pbp ||= quarters
end
- def drives
+ def drives_with_events
@drives_hash.values
end
+ def drives
+ drives_with_events.grep(Sportradar::Api::Football::Drive)
+ end
+
+
def plays
drives.flat_map(&:plays).compact
end
def events
@@ -369,10 +374,10 @@
end
def ingest_pbp(data)
data = data
update(data, source: :pbp)
- create_data(@quarters_hash, data[period_key], klass: quarter_class, identifier: 'number', api: api, game: self) if data[period_key]
+ create_data(@quarters_hash, data[period_key], klass: quarter_class, identifier: quarter_class.period_index, api: api, game: self) if data[period_key]
check_newness(:pbp, plays.last&.description)
check_newness(:score, @score)
@pbp = @quarters_hash.values
data
# rescue => e