Sha256: e13a0d5f6a80ef7f7ce635d5e746a4e12b259a77fa2b5845931bf81dd6efdd23

Contents?: true

Size: 986 Bytes

Versions: 105

Compression:

Stored size: 986 Bytes

Contents

module Sportradar
  module Api
    module Football
      class Situation < Data
        attr_accessor :response, :clock, :down, :yfd, :possession, :location, :team_id

        def initialize(data)
          @response   = data
          @clock      = data["clock"]
          @down       = data["down"]
          @yfd        = data["yfd"]
          @possession = OpenStruct.new(data["possession"]) if data["possession"]
          if data["location"]
            @location = OpenStruct.new(data["location"])
          elsif data['side'] && data['yard_line']
            @location = OpenStruct.new(alias: data['side'], yardline: data['yard_line'])
          end
          @team_id    = possession&.id || data["team"]
        end

        def spot
          [location&.alias, location&.yardline].compact.join(' ')
        end

        def distance
          @yfd
        end

        def down_distance
          [@down, distance].compact.join(' & ')
        end

      end
    end
  end
end

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
sportradar-api-0.13.14 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.13 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.12 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.11 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.10 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.9 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.8 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.7 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.6 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.5 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.4 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.3 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.2 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.1 lib/sportradar/api/football/situation.rb
sportradar-api-0.13.0 lib/sportradar/api/football/situation.rb
sportradar-api-0.12.3 lib/sportradar/api/football/situation.rb
sportradar-api-0.12.2 lib/sportradar/api/football/situation.rb
sportradar-api-0.12.1 lib/sportradar/api/football/situation.rb
sportradar-api-0.12.0 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.69 lib/sportradar/api/football/situation.rb