lib/traffic_jam/rolling_limit.rb
# Increment the amount used by the given number. Rolls back the increment
# if the operation exceeds the limit. Returns whether the operation was
# successful. Time of increment can be specified optionally with a keyword
# argument, which is not really useful since it be undone by used.
#
# @param amount [Integer] amount to increment by
# @param time [Time] time when increment occurs (ignored)
# @return [Boolean] true if increment succeded and false if incrementing
#   would exceed the limit
Increment the amount used by the given number. Rolls back the increment
if the operation exceeds the limit. Returns whether the operation was
successful. Time of increment can be specified optionally with a keyword
argument, which is not really useful since it be undone by used.
Increment the amount used by the given number . Rolls back the increment if the operation exceeds the limit . Returns whether the operation was successful . Time of increment can be specified optionally with a keyword argument which is not really useful since it be undone by used .
def increment(amount = 1, time: Time.now)
      raise ArgumentError, 'Amount must be an integer' if amount != amount.to_i
      return amount <= 0 if max.zero?
      return amount <= max if period.zero?
      return true if amount.zero?
      return false if amount > max
      !run_incr([time.to_i, amount.to_i, max, period]).nil?
    end
def increment ( amount = 1 , time : Time . now ) raise ArgumentError , 'Amount must be an integer' if amount != amount . to_i return amount <= 0 if max . zero? return amount <= max if period . zero? return true if amount . zero? return false if amount > max ! run_incr ( [ time . to_i , amount . to_i , max , period ] ) . nil? end
Increment the amount used by the given number.
Increment the amount used by the given number .
true if increment succeded and false if incrementing would exceed the limit
true if increment succeded and false if incrementing would exceed the limit
Boolean
amount
amount to increment by
amount to increment by
time
time when increment occurs (ignored)
time when increment occurs ( ignored )
now
<not_specific>