Class: Octokit::RateLimit
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Struct
|
|
Instance Chain:
self,
Struct
|
|
Inherits: |
Struct
|
Defined in: | lib/octokit/rate_limit.rb |
Overview
Class for API Rate Limit info
Class Method Summary
-
.from_response(response) ⇒ RateLimit
Get rate limit info from HTTP response.
Class Method Details
.from_response(response) ⇒ RateLimit
Get rate limit info from HTTP response
# File 'lib/octokit/rate_limit.rb', line 21
def self.from_response(response) info = new if response&.respond_to?(:headers) && !response.headers.nil? info.limit = (response.headers['X-RateLimit-Limit'] || 1).to_i info.remaining = (response.headers['X-RateLimit-Remaining'] || 1).to_i info.resets_at = Time.at((response.headers['X-RateLimit-Reset'] || Time.now).to_i) info.resets_in = [(info.resets_at - Time.now).to_i, 0].max end info end