Sha256: 05c9a0ae0d08e2c6e63d83f722f218be190eae3126fe445c3e534718a8423e4c

Contents?: true

Size: 1.09 KB

Versions: 184

Compression:

Stored size: 1.09 KB

Contents

module Sportradar
  module Api
    class Rank
      def initialize(data)
        @id        = data['id']
        @name      = data['name']
        @market    = data['market']
        @rank      = data['rank']
        @wins      = data['wins']
        @losses    = data['losses']
        @prev_rank = data['prev_rank']
        @points    = data['points'] || data['votes']
        @fp_votes  = data['fp_votes'].to_i
        if data['rpi']
          @rpi = data
        end
      end
    end
    class Poll
      def initialize(data)        
        @response = data

        @id       = data.dig('poll', 'id')
        @name     = data.dig('poll', 'name')
        @alias    = data.dig('poll', 'alias')
        @week     = data['week']
        @year     = data['year']
        @time     = data['effective_date']

        update(data)
      end
      def update(data)
        @ranked = data['rankings'].map { |h| Rank.new(h) }
        if @alias == 'AP' || @alias == 'US'
          @votes = data['candidates'].map.with_index(@ranked.size + 1) { |h, i| Rank.new(h.merge('rank' => i)) }
        end
      end
    end
  end
end

Version data entries

184 entries across 184 versions & 1 rubygems

Version Path
sportradar-api-0.10.43 lib/sportradar/api/poll.rb
sportradar-api-0.10.42 lib/sportradar/api/poll.rb
sportradar-api-0.10.41 lib/sportradar/api/poll.rb
sportradar-api-0.10.40 lib/sportradar/api/poll.rb
sportradar-api-0.10.39 lib/sportradar/api/poll.rb
sportradar-api-0.10.38 lib/sportradar/api/poll.rb
sportradar-api-0.10.37 lib/sportradar/api/poll.rb
sportradar-api-0.10.36 lib/sportradar/api/poll.rb
sportradar-api-0.10.35 lib/sportradar/api/poll.rb
sportradar-api-0.10.34 lib/sportradar/api/poll.rb
sportradar-api-0.10.33 lib/sportradar/api/poll.rb
sportradar-api-0.10.32 lib/sportradar/api/poll.rb
sportradar-api-0.10.31 lib/sportradar/api/poll.rb
sportradar-api-0.10.30 lib/sportradar/api/poll.rb
sportradar-api-0.10.29 lib/sportradar/api/poll.rb
sportradar-api-0.10.28 lib/sportradar/api/poll.rb
sportradar-api-0.10.27 lib/sportradar/api/poll.rb
sportradar-api-0.10.26 lib/sportradar/api/poll.rb
sportradar-api-0.10.25 lib/sportradar/api/poll.rb
sportradar-api-0.10.24 lib/sportradar/api/poll.rb