Module: Octokit::Client::RateLimit

Included in:
Octokit::Client
Defined in:
lib/octokit/client/rate_limit.rb

Overview

Methods for API rate limiting info

Instance Method Summary collapse

Instance Method Details

#rate_limit(_options = {}) ⇒ Octokit::RateLimit Also known as: ratelimit

Get rate limit info from last response if available or make a new request to fetch rate limit



14
15
16
17
18
# File 'lib/octokit/client/rate_limit.rb', line 14

def rate_limit(_options = {})
  return rate_limit! if last_response.nil?

  Octokit::RateLimit.from_response(last_response)
end

#rate_limit!(_options = {}) ⇒ Octokit::RateLimit Also known as: ratelimit!

Refresh rate limit info by making a new request



35
36
37
38
# File 'lib/octokit/client/rate_limit.rb', line 35

def rate_limit!(_options = {})
  get 'rate_limit'
  Octokit::RateLimit.from_response(last_response)
end

#rate_limit_remaining(_options = {}) ⇒ Integer Also known as: ratelimit_remaining

Get number of rate limted requests remaining

Returns:

  • (Integer)

    Number of requests remaining in this period

See Also:



25
26
27
28
# File 'lib/octokit/client/rate_limit.rb', line 25

def rate_limit_remaining(_options = {})
  octokit_warn 'Deprecated: Please use .rate_limit.remaining'
  rate_limit.remaining
end

#rate_limit_remaining!(_options = {}) ⇒ Integer Also known as: ratelimit_remaining!

Refresh rate limit info and get number of rate limted requests remaining

Returns:

  • (Integer)

    Number of requests remaining in this period

See Also:



45
46
47
48
# File 'lib/octokit/client/rate_limit.rb', line 45

def rate_limit_remaining!(_options = {})
  octokit_warn 'Deprecated: Please use .rate_limit!.remaining'
  rate_limit!.remaining
end