A setting that represents a span of time, and evaluates to an integer number of seconds after being parsed
A regex describing valid formats with groups for capturing the value and units
How we convert from various units to seconds.
Convert the value to an integer, parsing numeric string with units if necessary.
# File lib/puppet/settings/duration_setting.rb, line 24 def munge(value) case when value.is_a?(Integer) value when (value.is_a?(String) and value =~ FORMAT) $1.to_i * UNITMAP[$2 || 's'] else raise Puppet::Settings::ValidationError, "Invalid duration format '#{value.inspect}' for parameter: #{@name}" end end
# File lib/puppet/settings/duration_setting.rb, line 19 def type :duration end