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.68 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.67 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.66 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.65 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.64 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.63 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.62 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.61 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.60 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.59 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.58 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.57 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.56 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.55 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.54 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.53 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.52 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.51 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.50 lib/sportradar/api/football/situation.rb
sportradar-api-0.11.49 lib/sportradar/api/football/situation.rb