Class: Twitter::RateLimit

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter/rate_limit.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary (collapse)

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, deprecate_attribute_method, display_uri_attr_reader, #initialize, object_attr_reader, predicate_attr_reader, uri_attr_reader

Methods included from Utils

flat_pmap, pmap

Constructor Details

This class inherits a constructor from Twitter::Base

Instance Method Details

- (Integer) limit

Returns:

  • (Integer)


4
5
6
7
# File 'lib/twitter/rate_limit.rb', line 4

def limit
  limit = @attrs['x-rate-limit-limit']
  limit.to_i if limit
end

- (Integer) remaining

Returns:

  • (Integer)


11
12
13
14
# File 'lib/twitter/rate_limit.rb', line 11

def remaining
  remaining = @attrs['x-rate-limit-remaining']
  remaining.to_i if remaining
end

- (Time) reset_at

Returns:

  • (Time)


18
19
20
21
# File 'lib/twitter/rate_limit.rb', line 18

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

Returns:

  • (Integer)


25
26
27
# File 'lib/twitter/rate_limit.rb', line 25

def reset_in
  [(reset_at - Time.now).ceil, 0].max if reset_at
end