class Sportradar::Nfl::PlaySummaries

Public Class Methods

perform(year: nil, interval_type: nil, week: 1, away_team_abbreviation:, home_team_abbreviation:) click to toggle source
# File lib/sportradar/nfl/play_summaries.rb, line 4
def self.perform(year: nil,
                 interval_type: nil,
                 week: 1,
                 away_team_abbreviation:,
                 home_team_abbreviation:)
  new(year: year,
      interval_type: interval_type,
      week: week,
      away_team_abbreviation: away_team_abbreviation,
      home_team_abbreviation: home_team_abbreviation).perform
end

Public Instance Methods

perform() click to toggle source
# File lib/sportradar/nfl/play_summaries.rb, line 16
def perform
  (quarters || []).each do |quarter|
    (quarter['pbp'] || []).each do |pbp|
      (pbp['actions'] || []).each do |action|
        next unless action['type'] == 'play'

        PlaySummary.new(week: @week,
                        year: @year,
                        interval_type: @interval_type,
                        away_team_abbreviation: @away_team_abbreviation,
                        home_team_abbreviation: @home_team_abbreviation,
                        play_id: action['id']).save
      end
    end
  end

  nil
end

Private Instance Methods

quarters() click to toggle source
# File lib/sportradar/nfl/play_summaries.rb, line 37
def quarters
  fetch['quarters'] || []
end