Simple Switch
A simple switch is an argument with no optional forms or no parameters. The effect will be to simply set a flag in the options hash. No other parameters will be passed to the on method.
options[:simple] = false
opts.on( ‘-s’, ‘–simple’, “Simple argument” ) do
options[:simple] = true
end
Switch with Mandatory Parameter
Switches that take a parameter only need to state the parameter name in the long form of the switch. For example, “-s”, “–simple Simple” means the -f or –file switch takes a single parameter called Simple, and this parameter is mandatory. You cannot use either -f or –file without also passing it a parameter.
options[:simple] = “”
opts.on( ‘-s’, ‘–simple Simple’, “simple with an argument” ) do|f|
options[:simple] = f
end
If without ‘Simple’ inside ‘–simple Simple’, the value of f will be switch value: true or false, rather than the real simplevalue in the command line”–simple simplevalue”