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.11.48 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.47 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.46 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.45 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.44 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.43 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.42 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.41 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.40 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.39 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.38 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.37 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.36 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.35 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.34 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.33 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.32 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.31 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.30 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.29 lib/sportradar/api/football/situation.rb