Class: Puppet::Util::Settings::BooleanSetting
- Defined in:
- lib/vendor/puppet/util/settings/boolean_setting.rb
Overview
A simple boolean.
Instance Attribute Summary
Attributes inherited from Setting
#call_on_define, #default, #desc, #name, #section, #setbycli, #short
Instance Method Summary collapse
-
#getopt_args ⇒ Object
get the arguments in getopt format.
- #munge(value) ⇒ Object
- #optparse_args ⇒ Object
Methods inherited from Setting
#hook=, #initialize, #iscreated, #iscreated?, #set?, #to_config, #value
Constructor Details
This class inherits a constructor from Puppet::Util::Settings::Setting
Instance Method Details
#getopt_args ⇒ Object
get the arguments in getopt format
6 7 8 9 10 11 12 |
# File 'lib/vendor/puppet/util/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/vendor/puppet/util/settings/boolean_setting.rb', line 22 def munge(value) case value when true, "true"; return true when false, "false"; return false else raise ArgumentError, "Invalid value '#{value.inspect}' for #{@name}" end end |
#optparse_args ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/vendor/puppet/util/settings/boolean_setting.rb', line 14 def optparse_args if short ["--[no-]#{name}", "-#{short}", desc, :NONE ] else ["--[no-]#{name}", desc, :NONE] end end |