lib/pulse_meter/mixins/utils.rb
# Ensures that hash value specified by key can be converted to positive integer.
# In case it can makes in-place conversion and returns the value.
# @param options [Hash] hash to be looked at
# @param key [Object] hash key
# @param default [Object] default value to be returned
# @raise [ArgumentError] unless value is positive integer
# @return [Fixnum]
Ensures that hash value specified by key can be converted to positive integer.
In case it can makes in-place conversion and returns the value.
Ensures that hash value specified by key can be converted to positive integer . In case it can makes in - place conversion and returns the value .
def assert_positive_integer!(options, key, default = nil)
        value = options[key] || default
        raise ArgumentError, "#{key} should be defined" unless value
        raise ArgumentError, "#{key} should be integer" unless value.respond_to?(:to_i)
        raise ArgumentError, "#{key} should be positive" unless value.to_i > 0
        options[key] = value.to_i
      end
def assert_positive_integer! ( options , key , default = nil ) value = options [ key ] || default raise ArgumentError , "#{key} should be defined" unless value raise ArgumentError , "#{key} should be integer" unless value . respond_to? ( :to_i ) raise ArgumentError , "#{key} should be positive" unless value . to_i > 0 options [ key ] = value . to_i end
Ensures that hash value specified by key can be converted to positive integer.
Ensures that hash value specified by key can be converted to positive integer .
None
Fixnum
[ArgumentError] unless value is positive integer
[ ArgumentError ] unless value is positive integer
options
hash to be looked at
hash to be looked at
key
None
default
default value to be returned
default value to be returned