Sha256: 82af716f7cf1bde01059b4622667812210e9ac34a5d4c07a069987e29fb92496

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

module Octokit

  # Class for API Rate Limit info
  #
  # @see http://developer.github.com/v3/#rate-limiting
  class RateLimit < Struct.new :limit, :remaining

    # Get rate limit info from HTTP response
    #
    # @param response [#headers] HTTP response
    # @return [RateLimit]
    def self.from_response(response)
      info = new
      if response && !response.headers.nil?
        info.limit = response.headers['X-RateLimit-Limit'].to_i
        info.remaining = response.headers['X-RateLimit-Remaining'].to_i
      end

      info
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
octokit-2.0.0.pre lib/octokit/rate_limit.rb