lib/sportradar/api/football/play_statistics.rb in sportradar-api-0.11.26 vs lib/sportradar/api/football/play_statistics.rb in sportradar-api-0.11.27

- old
+ new

@@ -15,11 +15,21 @@ klass = self.class.stat_type_classes[hash['stat_type']] || MiscStatistics var << klass.new(hash) end end + def players + @players ||= [:kick, :return, :rush, :defense, :receive, :punt, :penalty, :pass, :first_down, :field_goal, :extra_point, :defense, :down_conversion].flat_map do |stat_type| + Array(send(stat_type)).map { |stat| stat.player.team = stat.team.id; stat.player } + end + end + + def players_by_team + @players_by_team ||= players.group_by(&:team) + end + def self.stat_type_classes - stat_type_classes ||= { + @stat_type_classes ||= { 'kick' => PlayKickStatistics, 'return' => PlayReturnStatistics, 'rush' => PlayRushStatistics, 'fumble' => PlayFumbleStatistics, 'defense' => PlayDefenseStatistics, \ No newline at end of file