Class: Twitter::RateLimit

Inherits:
Base
  • Object
show all
Includes:
Memoizable
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, 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

#limitInteger

Returns:

  • (Integer)


8
9
10
11
# File 'lib/twitter/rate_limit.rb', line 8

def limit
  limit = @attrs["x-rate-limit-limit"]
  limit&.to_i
end

#remainingInteger

Returns:

  • (Integer)


15
16
17
18
# File 'lib/twitter/rate_limit.rb', line 15

def remaining
  remaining = @attrs["x-rate-limit-remaining"]
  remaining&.to_i
end

#reset_atTime

Returns:

  • (Time)


22
23
24
25
# File 'lib/twitter/rate_limit.rb', line 22

def reset_at
  reset = @attrs["x-rate-limit-reset"]
  Time.at(reset.to_i).utc if reset
end

#reset_inInteger Also known as: retry_after

Returns:

  • (Integer)


29
30
31
# File 'lib/twitter/rate_limit.rb', line 29

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