Class: Puppet::Settings::BooleanSetting

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

Overview

A simple boolean.

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


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

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


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

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


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

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

#typeObject


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

def type
  :boolean
end