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



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

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



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

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

#optparse_argsObject



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

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

#typeObject



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

def type
  :boolean
end