class Puppet::Settings::DurationSetting

A setting that represents a span of time, and evaluates to an integer number of seconds after being parsed

Constants

FORMAT

A regex describing valid formats with groups for capturing the value and units

UNITMAP

How we convert from various units to seconds.

Public Instance Methods

munge(value) click to toggle source

Convert the value to an integer, parsing numeric string with units if necessary.

   # File lib/puppet/settings/duration_setting.rb
22 def munge(value)
23   case
24   when value.is_a?(Integer) || value.nil?
25     value
26   when (value.is_a?(String) and value =~ FORMAT)
27     $1.to_i * UNITMAP[$2 || 's']
28   else
29     raise Puppet::Settings::ValidationError, _("Invalid duration format '%{value}' for parameter: %{name}") % { value: value.inspect, name: @name }
30   end
31 end
type() click to toggle source
   # File lib/puppet/settings/duration_setting.rb
17 def type
18   :duration
19 end