Sha256: 3de1111ba0928a8380ec1a3e7e70d1143119b16c4ed7346799336beb5882d874
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
module Hackeroo class RateLimit attr_reader :attrs alias to_hash attrs # @return [Hackeroo::RateLimit] def initialize(attrs={}) @attrs = attrs end # @return [Integer] def limit limit = @attrs['x-rate-limit-limit'] limit.to_i if limit end # @return [Integer] def remaining remaining = @attrs['x-rate-limit-remaining'] remaining.to_i if remaining end # @return [Time] def reset_at reset = @attrs['x-rate-limit-reset'] Time.at(reset.to_i) if reset end # @return [Integer] def reset_in [(reset_at - Time.now).ceil, 0].max if reset_at end alias retry_after reset_in # Update the attributes of a RateLimit # # @param attrs [Hash] # @return [Hackeroo::RateLimit] def update(attrs) @attrs.update(attrs) self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hackeroo-0.1.0 | lib/hackeroo/rate_limit.rb |