Sha256: c5e6300206075ad3c2670b85960bad0e279b781ca4fc81edbce466c74aa7866f

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

module Sportradar
  module Api
    module Football
      class Ncaafb
        class Drive < Sportradar::Api::Football::Drive

          alias :team_id :team

          def update(data, **opts)
            super.tap {
              @sequence = (opts[:game].drives.index(self) || opts[:game].drives.size) + 1 if opts[:game]
            }
          end

          def end_reason
            plays.last.parsed_ending || 'UNKNOWN'
          end

          def over?
            plays.last&.parsed_ending || (overtime? && ['End of Quarter', 'End of Game'].include?(plays.last&.description))
          end

          def handle_plays_and_events(data, **opts)
            create_data(@plays_hash,  data['actions'],  klass: Play,  api: api, drive: self) if data['actions']
            create_data(@events_hash, data['events'],   klass: Event, api: api, drive: self) if data['events']
          end

          def play_count
            plays.count(&:counted_play?)
          end

          def gain
            Array(plays.select(&:counted_play?)).map(&:yards).inject(:+).to_i
          end

        end
      end
    end
  end
end
# e = Event.find 17632;
# sc = e.sportconnector_game;
# dr = sc.pbp[-3]
# pl = dr.plays.last

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sportradar-api-0.11.40 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.39 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.38 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.37 lib/sportradar/api/football/ncaafb/drive.rb