Class: Puppet::Settings::BooleanSetting

Inherits:
BaseSetting show all
Defined in:
lib/puppet/settings/boolean_setting.rb

Overview

A simple boolean.

Constant Summary

Constants inherited from BaseSetting

Puppet::Settings::BaseSetting::HOOK_TYPES

Instance Attribute Summary

Attributes inherited from BaseSetting

#call_hook, #default, #deprecated, #desc, #name, #section, #short

Instance Method Summary collapse

Methods inherited from BaseSetting

#allowed_on_commandline?, available_call_hook_values, #call_hook_on_define?, #call_hook_on_initialize?, #completely_deprecated?, #deprecated?, #has_hook?, #hook=, #initialize, #inspect, #iscreated, #iscreated?, #print, #set_meta, #to_config, #value

Constructor Details

This class inherits a constructor from Puppet::Settings::BaseSetting

Instance Method Details

#getopt_argsObject

get the arguments in getopt format



6
7
8
9
10
11
12
# File 'lib/puppet/settings/boolean_setting.rb', line 6

def getopt_args
  if short
    [["--#{name}", "-#{short}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
  else
    [["--#{name}", GetoptLong::NO_ARGUMENT], ["--no-#{name}", GetoptLong::NO_ARGUMENT]]
  end
end

#munge(value) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/puppet/settings/boolean_setting.rb', line 22

def munge(value)
  case value
  when true, "true"; true
  when false, "false"; false
  else
    raise Puppet::Settings::ValidationError, _("Invalid value '%{value}' for boolean parameter: %{name}") % { value: value.inspect, name: @name }
  end
end

#optparse_argsObject



14
15
16
17
18
19
20
# File 'lib/puppet/settings/boolean_setting.rb', line 14

def optparse_args
  if short
    ["--[no-]#{name}", "-#{short}", desc, :NONE]
  else
    ["--[no-]#{name}", desc, :NONE]
  end
end

#typeObject



31
32
33
# File 'lib/puppet/settings/boolean_setting.rb', line 31

def type
  :boolean
end