Sha256: fd703d0f681f9195f4aeb66f198a54bc3c0a1bcaa70d0c055551d88ca61c69e1

Contents?: true

Size: 644 Bytes

Versions: 17

Compression:

Stored size: 644 Bytes

Contents

module Twitter
  class RateLimit < Twitter::Base
    # @return [Integer]
    def limit
      limit = @attrs['x-rate-limit-limit']
      limit.to_i if limit
    end
    memoize :limit

    # @return [Integer]
    def remaining
      remaining = @attrs['x-rate-limit-remaining']
      remaining.to_i if remaining
    end
    memoize :remaining

    # @return [Time]
    def reset_at
      reset = @attrs['x-rate-limit-reset']
      Time.at(reset.to_i) if reset
    end
    memoize :reset_at

    # @return [Integer]
    def reset_in
      [(reset_at - Time.now).ceil, 0].max if reset_at
    end
    alias_method :retry_after, :reset_in
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
twitter-5.14.0 lib/twitter/rate_limit.rb
twitter-5.13.0 lib/twitter/rate_limit.rb
twitter-5.12.0 lib/twitter/rate_limit.rb
twitter-5.11.0 lib/twitter/rate_limit.rb
twitter-5.10.0 lib/twitter/rate_limit.rb
twitter-5.9.0 lib/twitter/rate_limit.rb
twitter-5.8.0 lib/twitter/rate_limit.rb
twitter-5.7.1 lib/twitter/rate_limit.rb
twitter-5.7.0 lib/twitter/rate_limit.rb
twitter-5.6.0 lib/twitter/rate_limit.rb
twitter-5.5.1 lib/twitter/rate_limit.rb
twitter-5.5.0 lib/twitter/rate_limit.rb
twitter-5.4.1 lib/twitter/rate_limit.rb
twitter-5.4.0 lib/twitter/rate_limit.rb
twitter-5.3.1 lib/twitter/rate_limit.rb
twitter-5.3.0 lib/twitter/rate_limit.rb
twitter-5.2.0 lib/twitter/rate_limit.rb