lib/sportradar/api/soccer/match.rb in sportradar-api-0.13.16 vs lib/sportradar/api/soccer/match.rb in sportradar-api-0.13.17
- old
+ new
@@ -21,12 +21,12 @@
@timeline_hash = {}
@lineups_hash = {}
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)
+ @home = Team.new(data['home'].to_h, api: api, match: self)
+ @away = Team.new(data['away'].to_h, api: api, match: self)
@teams_hash = { away: @away, home: @home }
@team_ids = { away: @away.id, home: @home.id }
@team_stats = {}
@player_stats = {}
@@ -223,9 +223,22 @@
@timeline_hash.each_value.select { |ev| ev.type == type }
else
@timeline_hash.values
end
end
+
+ def timeline_by_minute(minute_start, minute_end = nil)
+ if minute_end
+ @timeline_hash.each_value.select { |ev| (minute_start..minute_end).cover?(ev.match_time.to_i) }
+ else
+ @timeline_hash.each_value.select { |ev| minute_start === ev.match_time }
+ end
+ end
+
+ def plays_by_minute(type, minute_start, minute_end = nil)
+ timeline_by_minute(minute_start, minute_end).select { |ev| ev.type == type }
+ end
+
def lineups(which = nil)
if which
@lineups_hash[which.to_s]
else