Method: Puppet::Settings::DurationSetting#munge
- Defined in:
- lib/puppet/settings/duration_setting.rb
#munge(value) ⇒ Object
Convert the value to an integer, parsing numeric string with units if necessary.
24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/settings/duration_setting.rb', line 24 def munge(value) if value.is_a?(Integer) || value.nil? value elsif value.is_a?(String) and value =~ FORMAT ::Regexp.last_match(1).to_i * UNITMAP[::Regexp.last_match(2) || 's'] else raise Puppet::Settings::ValidationError, _("Invalid duration format '%{value}' for parameter: %{name}") % { value: value.inspect, name: @name } end end |