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