Class: Uber::RateLimit

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

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], #initialize

Constructor Details

This class inherits a constructor from Uber::Base

Instance Method Details

#limitInteger

Returns:

  • (Integer)


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

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

#remainingInteger

Returns:

  • (Integer)


10
11
12
13
# File 'lib/uber/rate_limit.rb', line 10

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

#reset_atTime

Returns:



16
17
18
19
# File 'lib/uber/rate_limit.rb', line 16

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

#reset_inInteger

Returns:

  • (Integer)


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

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