Parent

Class/Module Index [+]

Quicksearch

Twitter::RateLimit

Attributes

attrs[R]
to_hash[R]

Public Class Methods

instance() click to toggle source

@deprecated This method exists to provide backwards compatibility to when

Twitter::RateLimit was a singleton. Safe to remove in version 4.
# File lib/twitter/rate_limit.rb, line 8
def self.instance
  Twitter.rate_limit
end
new(attrs={}) click to toggle source

@return [Twitter::RateLimit]

# File lib/twitter/rate_limit.rb, line 13
def initialize(attrs={})
  @attrs = attrs
end

Public Instance Methods

class() click to toggle source

@return [String]

# File lib/twitter/rate_limit.rb, line 18
def class
  @attrs.values_at('x-ratelimit-class', 'X-RateLimit-Class').compact.first
end
limit() click to toggle source

@return [Integer]

# File lib/twitter/rate_limit.rb, line 23
def limit
  limit = @attrs.values_at('x-ratelimit-limit', 'X-RateLimit-Limit').compact.first
  limit.to_i if limit
end
remaining() click to toggle source

@return [Integer]

# File lib/twitter/rate_limit.rb, line 29
def remaining
  remaining = @attrs.values_at('x-ratelimit-remaining', 'X-RateLimit-Remaining').compact.first
  remaining.to_i if remaining
end
reset_at() click to toggle source

@return [Time]

# File lib/twitter/rate_limit.rb, line 35
def reset_at
  reset = @attrs.values_at('x-ratelimit-reset', 'X-RateLimit-Reset').compact.first
  Time.at(reset.to_i) if reset
end
reset_in() click to toggle source

@return [Integer]

# File lib/twitter/rate_limit.rb, line 41
def reset_in
  if retry_after = @attrs.values_at('retry-after', 'Retry-After').compact.first
    retry_after.to_i
  elsif reset_at
    [(reset_at - Time.now).ceil, 0].max
  end
end
Also aliased as: retry_after
retry_after() click to toggle source
Alias for: reset_in
update(attrs) click to toggle source

Update the attributes of a Relationship

@param attrs [Hash] @return [Twitter::RateLimit]

# File lib/twitter/rate_limit.rb, line 54
def update(attrs)
  @attrs.update(attrs)
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.