class Echowrap::RateLimit

Attributes

attrs[R]
to_hash[R]

Public Class Methods

new(attrs={}) click to toggle source

@return [Echowrap::RateLimit]

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

Public Instance Methods

limit() click to toggle source

@return [Integer]

# File lib/echowrap/rate_limit.rb, line 14
def limit
  limit = @attrs['x-rate-limit-limit']
  limit.to_i if limit
end
remaining() click to toggle source

@return [Integer]

# File lib/echowrap/rate_limit.rb, line 20
def remaining
  remaining = @attrs['x-rate-limit-remaining']
  remaining.to_i if remaining
end
reset_at() click to toggle source

@return [Time]

# File lib/echowrap/rate_limit.rb, line 26
def reset_at
  reset = @attrs['x-rate-limit-reset']
  Time.at(reset.to_i) if reset
end
reset_in() click to toggle source

@return [Integer]

# File lib/echowrap/rate_limit.rb, line 32
def reset_in
  [(reset_at - Time.now).ceil, 0].max if reset_at
end
Also aliased as: retry_after
retry_after()
Alias for: reset_in
update(attrs) click to toggle source

Update the attributes of a RateLimit

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

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