Puppet Function: parse_scheduled_install_day
- Defined in:
- lib/puppet/parser/functions/parse_scheduled_install_day.rb
- Function type:
- Ruby 3.x API
Summary
Parse the incoming value to the corresponding integer, if integer is supplied simply return valueOverview
> Note: Valid options for scheduled_install_day are Everyday|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|0-7
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/parser/functions/parse_scheduled_install_day.rb', line 6 newfunction(:parse_scheduled_install_day, type: :rvalue, arity: 1, doc: <<-EOS @summary Parse the incoming value to the corresponding integer, if integer is supplied simply return value @return [Integer] option scheduled_install_day as an integer > *Note:* Valid options for scheduled_install_day are Everyday|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|0-7 EOS ) do |args| day_hash = { 'Everyday' => 0, 'Sunday' => 1, 'Monday' => 2, 'Tuesday' => 3, 'Wednesday' => 4, 'Thursday' => 5, 'Friday' => 6, 'Saturday' => 7 } option = args[0] if option.is_a?(Numeric) || option =~ %r{^\d$} if option.is_a?(String) option = Integer(option) end if option < 0 || option > 7 raise Puppet::ParseError, "Valid options for scheduled_install_day are #{day_hash.keys.join('|')}|0-7, provided '#{option}'" end return option end if day_hash.key?(option.capitalize) return day_hash[option.capitalize] end raise Puppet::ParseError, "Valid options for scheduled_install_day are #{day_hash.keys.join('|')}|0-7, provided '#{option}'" end |