lib/polyphony/core/throttler.rb
# Converts the given argument to a rate. If a hash is given, the throttler's
# rate is computed from the value of either the `:interval` or `:rate` keys.
#
# @param arg [Number, Hash] rate argument
# @return [Number] rate in times per second
Converts the given argument to a rate. If a hash is given, the throttler's
rate is computed from the value of either the `:interval` or `:rate` keys.
Converts the given argument to a rate . If a hash is given the throttler ' s rate is computed from the value of either the ` : interval ` or ` : rate ` keys .
def rate_from_argument(arg)
      return arg if arg.is_a?(Numeric)
      if arg.is_a?(Hash)
        return 1.0 / arg[:interval] if arg[:interval]
        return arg[:rate] if arg[:rate]
      end
      raise "Invalid rate argument #{arg.inspect}"
    end
def rate_from_argument ( arg ) return arg if arg . is_a? ( Numeric ) if arg . is_a? ( Hash ) return 1.0 / arg [ :interval ] if arg [ :interval ] return arg [ :rate ] if arg [ :rate ] end raise "Invalid rate argument #{arg.inspect}" end
Converts the given argument to a rate.
Converts the given argument to a rate .
rate in times per second
rate in times per second
Number
arg
None