Sha256: 6ee762354e7f8fc067d5d1b1e172d469c045a51685a7ccfe610891cbcdf25658

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Sportradar
  module Api
    class Nfl::Drive < Data
      attr_accessor :response, :id, :sequence, :start_reason, :end_reason, :play_count, :duration, :first_downs, :gain, :penalty_yards, :scoring_drive, :quarter, :team, :plays

      def initialize(data)
        @response = data
        @id = data["id"]
        @sequence = data["sequence"]
        @start_reason = data["start_reason"]
        @end_reason = data["end_reason"]
        @play_count = data["play_count"]
        @duration = data["duration"]
        @first_downs = data["first_downs"]
        @gain = data["gain"]
        @penalty_yards = data["penalty_yards"]
        @scoring_drive = data["scoring_drive"]
        @quarter = Sportradar::Api::Nfl::Quarter.new data["quarter"] if data["quarter"]
        @team = Sportradar::Api::Nfl::Team.new data["team"] if data["team"]
        @plays = parse_into_array(selector: response["play"], klass: Sportradar::Api::Nfl::Play) if response["play"]
        @plays ||= parse_into_array(selector: response["plays"]["play"], klass: Sportradar::Api::Nfl::Play) if response["plays"] && response["plays"]["play"]
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sportradar-api-0.9.7 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.6 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.5 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.3 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.2 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.1 lib/sportradar/api/nfl/drive.rb
sportradar-api-0.9.0 lib/sportradar/api/nfl/drive.rb