lib/sportradar/api/basketball/nba/quarter.rb in sportradar-api-0.13.4 vs lib/sportradar/api/basketball/nba/quarter.rb in sportradar-api-0.13.5
- old
+ new
@@ -31,11 +31,18 @@
update(data)
end
def update(data, **opts)
create_data(@plays_hash, data.dig('events'), klass: Play, api: @api, quarter: self)
- # rescue => e
- # binding.pry
+ end
+
+ def plays_by_type(play_type, *types)
+ if types.empty?
+ plays.grep(Play.subclass(play_type.delete('_')))
+ else
+ play_classes = [play_type, *types].map { |type| Play.subclass(type.delete('_')) }
+ plays.select { |play| play_classes.any? { |klass| play.kind_of?(klass) } }
+ end
end
def plays
@plays_hash.values
end