Class: Twitter::RateLimit
- Inherits:
-
Object
- Object
- Twitter::RateLimit
- Defined in:
- lib/twitter/rate_limit.rb
Instance Attribute Summary (collapse)
-
- (Object) attrs
(also: #to_hash)
readonly
Returns the value of attribute attrs.
Instance Method Summary (collapse)
- - (Twitter::RateLimit) initialize(attrs = {}) constructor
- - (Integer) limit
- - (Integer) remaining
- - (Time) reset_at
- - (Integer) reset_in (also: #retry_after)
-
- (Twitter::RateLimit) update(attrs)
Update the attributes of a RateLimit.
Constructor Details
- (Twitter::RateLimit) initialize(attrs = {})
7 8 9 |
# File 'lib/twitter/rate_limit.rb', line 7 def initialize(attrs={}) @attrs = attrs end |
Instance Attribute Details
- (Object) attrs (readonly) Also known as: to_hash
Returns the value of attribute attrs
3 4 5 |
# File 'lib/twitter/rate_limit.rb', line 3 def attrs @attrs end |
Instance Method Details
- (Integer) limit
12 13 14 15 |
# File 'lib/twitter/rate_limit.rb', line 12 def limit limit = @attrs['x-rate-limit-limit'] limit.to_i if limit end |
- (Integer) remaining
18 19 20 21 |
# File 'lib/twitter/rate_limit.rb', line 18 def remaining remaining = @attrs['x-rate-limit-remaining'] remaining.to_i if remaining end |
- (Time) reset_at
24 25 26 27 |
# File 'lib/twitter/rate_limit.rb', line 24 def reset_at reset = @attrs['x-rate-limit-reset'] Time.at(reset.to_i) if reset end |
- (Integer) reset_in Also known as: retry_after
30 31 32 |
# File 'lib/twitter/rate_limit.rb', line 30 def reset_in [(reset_at - Time.now).ceil, 0].max if reset_at end |
- (Twitter::RateLimit) update(attrs)
Update the attributes of a RateLimit
39 40 41 42 |
# File 'lib/twitter/rate_limit.rb', line 39 def update(attrs) @attrs.update(attrs) self end |