module Foxy::RateLimit

Attributes

rate_limit[R]

Private Instance Methods

interval() click to toggle source
# File lib/foxy/rate_limit.rb, line 7
def interval
  1.0 / rate_limit
end
wait!() click to toggle source
# File lib/foxy/rate_limit.rb, line 11
def wait!
  return unless rate_limit
  @last ||= 0
  delta = interval - (Time.now.to_f - @last.to_f)
  sleep(delta) if delta > 0
  @last = Time.now.to_f
end