Sha256: a617e5df5baaf4940a9b709513179c545b8b629a5242cb0eadc40da6afa2c8d0

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 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 = OpenStruct.new data["statistics"] if data["statistics"] # TODO Implement statistics?
        if @statistics
          play_stats = @statistics.penalty || @statistics.rush || @statistics.return || @statistics.receive
          @player_id = play_stats.dig('player', 'id') if play_stats
        end
        @type = data["type"]
        @wall_clock = data["wall_clock"]
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sportradar-api-0.1.38 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.37 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.36 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.35 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.34 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.33 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.32 lib/sportradar/api/nfl/play.rb
sportradar-api-0.1.31 lib/sportradar/api/nfl/play.rb