Sha256: 8e8b234c49a6454fa5c9bd6dc91fb9fd423514a0ecccd70d863bbc4e0ab0e1f1

Contents?: true

Size: 1.69 KB

Versions: 101

Compression:

Stored size: 1.69 KB

Contents

module Sportradar
  module Api
    class Nfl::Play < Data
      attr_accessor :response, :id, :sequence, :reference, :clock, :home_points, :away_points, :type, :play_clock, :wall_clock, :start_situation, :end_situation, :description, :alt_description, :statistics, :score, :scoring_play, :team_id, :player_id

      def initialize(data)
        @response = data
        @alt_description = data["alt_description"]
        @away_points = data["away_points"]
        @clock = data["clock"]
        @description = data["description"]
        @end_situation = Sportradar::Api::Nfl::Situation.new data["end_situation"] if data["end_situation"]
        @team_id = end_situation.team_id if end_situation
        @home_points = data["home_points"]
        @id = data["id"]
        @play_clock = data["play_clock"]
        @reference = data["reference"]
        @score = data["score"]
        @scoring_play = data["scoring_play"]
        @sequence = data["sequence"]
        @start_situation = Sportradar::Api::Nfl::Situation.new data["start_situation"] if data["start_situation"]
        @statistics = Sportradar::Api::Nfl::PlayStatistics.new data["statistics"] if data["statistics"]
        parse_player if @statistics
        @type = data["type"]
        @wall_clock = data["wall_clock"]
      end

      def parse_player
        # TODO: Currently there is an issue where we are only mapping one player_id to a play, but there are plays with multiple players involved.
        play_stats = @statistics.penalty || @statistics.rush || @statistics.return || @statistics.receive
        if play_stats.is_a?(Array)
          play_stats = play_stats.first
        end
        @player_id = play_stats&.player&.id
      end

    end
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
sportradar-api-0.10.15 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.14 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.13 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.12 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.11 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.10 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.9 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.8 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.7 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.6 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.5 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.4 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.3 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.2 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.1 lib/sportradar/api/nfl/play.rb
sportradar-api-0.10.0 lib/sportradar/api/nfl/play.rb
sportradar-api-0.9.59 lib/sportradar/api/nfl/play.rb
sportradar-api-0.9.58 lib/sportradar/api/nfl/play.rb
sportradar-api-0.9.57 lib/sportradar/api/nfl/play.rb
sportradar-api-0.9.56 lib/sportradar/api/nfl/play.rb