lib/sportradar/api/soccer/match.rb in sportradar-api-0.13.11 vs lib/sportradar/api/soccer/match.rb in sportradar-api-0.13.12
- old
+ new
@@ -24,10 +24,13 @@
get_tournament_id(data, **opts)
@scoring_raw = Scoring.new(data, game: self)
@home = Team.new({}, api: api, match: self)
@away = Team.new({}, api: api, match: self)
@teams_hash = { away: @away, home: @home }
+ @team_ids = { away: @away.id, home: @home.id }
+ @team_stats = {}
+ @player_stats = {}
update(data, **opts)
end
def update(data, **opts)
@@ -181,10 +184,21 @@
if home_hash && away_hash
@home.update(home_hash, match: self)
@away.update(away_hash, match: self)
@teams_hash[@home.id] = @home
@teams_hash[@away.id] = @away
+ @team_ids = { away: @away.id, home: @home.id }
end
+ end
+
+ def update_stats(team, stats)
+ @team_stats.merge!(team.id => stats.merge(team: team))
+ end
+ def update_player_stats(player, stats)
+ @player_stats.merge!(player.id => stats.merge!(player: player))
+ end
+ def stats(team_id)
+ team_id.is_a?(Symbol) ? @team_stats[@team_ids[team_id]] : @team_stats[team_id]
end
def get_tournament_id(data, **opts)
@tournament_id ||= if opts[:tournament]
opts[:tournament].id