Sha256: 78dd19c18d0a7b2cbd551c06e31b81fa3176048e07fabb06779ebcc6dad2d5c7

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module Otter

  class Response
    attr_reader :headers,
                :response

    def initialize(headers, response) # :nodoc:
      @headers = headers
      @response = response
    end

    # Total credits that can be allocated.
    def rate_limit
      Integer(self.headers['X_RATELIMIT_LIMIT'])
    end

    # Total credits available.
    def rate_remaining
      Integer(self.headers['X_RATELIMIT_REMAINING'])
    end

    # Time when the credits will be reset.
    def rate_reset
      Time.at(Integer(self.headers['X_RATELIMIT_RESET']))
    end

    # Total number of results
    def total
      Integer(self.response['page'])
    end

    # Current page
    def page
      Integer(self.response['total'])
    end

    # Number of results per page
    def perpage
      Integer(self.response['perpage'])
    end

    def window
      self.response['window']
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
otter-rb-0.0.1 lib/otter/response.rb