Sha256: 1fca148a950cfb2f02ff91bf0b37d4a90c0d424bd08db4e568089c4ca09fd727

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

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

          alias :team_id :team

          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?)).sum do |play|
              Array(play.players).sum do |p|
                p.dig('passing', 'yds').to_i + p.dig('rushing', 'yds').to_i
              end
            end
          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

8 entries across 8 versions & 1 rubygems

Version Path
sportradar-api-0.11.31 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.30 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.29 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.28 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.27 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.26 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.25 lib/sportradar/api/football/ncaafb/drive.rb
sportradar-api-0.11.24 lib/sportradar/api/football/ncaafb/drive.rb