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.28 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.27 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.26 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.25 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.24 lib/sportradar/api/football/situation.rb