Class: Octokit::RateLimit
- Inherits:
-
Struct
- Object
- Struct
- Octokit::RateLimit
- Defined in:
- lib/octokit/rate_limit.rb
Overview
Class for API Rate Limit info
Instance Attribute Summary collapse
-
#limit ⇒ Fixnum
writeonly
Max tries per rate limit period.
-
#remaining ⇒ Fixnum
writeonly
Remaining tries per rate limit period.
-
#resets_at ⇒ Time
writeonly
Indicates when rate limit resets.
-
#resets_in ⇒ Fixnum
writeonly
Number of seconds when rate limit resets.
Class Method Summary collapse
-
.from_response(response) ⇒ RateLimit
Get rate limit info from HTTP response.
Instance Attribute Details
#limit=(value) ⇒ Fixnum (writeonly)
Returns Max tries per rate limit period.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octokit/rate_limit.rb', line 15 class RateLimit < Struct.new :limit, :remaining, :resets_at, :resets_in # 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 info.resets_at = Time.at(response.headers['X-RateLimit-Reset'].to_i) info.resets_in = (info.resets_at - Time.now).to_i end info end end |
#remaining=(value) ⇒ Fixnum (writeonly)
Returns Remaining tries per rate limit period.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octokit/rate_limit.rb', line 15 class RateLimit < Struct.new :limit, :remaining, :resets_at, :resets_in # 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 info.resets_at = Time.at(response.headers['X-RateLimit-Reset'].to_i) info.resets_in = (info.resets_at - Time.now).to_i end info end end |
#resets_at=(value) ⇒ Time (writeonly)
Returns Indicates when rate limit resets.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octokit/rate_limit.rb', line 15 class RateLimit < Struct.new :limit, :remaining, :resets_at, :resets_in # 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 info.resets_at = Time.at(response.headers['X-RateLimit-Reset'].to_i) info.resets_in = (info.resets_at - Time.now).to_i end info end end |
#resets_in=(value) ⇒ Fixnum (writeonly)
Returns Number of seconds when rate limit resets.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octokit/rate_limit.rb', line 15 class RateLimit < Struct.new :limit, :remaining, :resets_at, :resets_in # 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 info.resets_at = Time.at(response.headers['X-RateLimit-Reset'].to_i) info.resets_in = (info.resets_at - Time.now).to_i end info end end |
Class Method Details
.from_response(response) ⇒ RateLimit
Get rate limit info from HTTP response
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/octokit/rate_limit.rb', line 21 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 info.resets_at = Time.at(response.headers['X-RateLimit-Reset'].to_i) info.resets_in = (info.resets_at - Time.now).to_i end info end |