Class: Ame::Switch
Overview
Represents an option to a Method that takes an optional argument. If an explicit (‘=’-separated) argument is given, it’ll be used, otherwise a default value, which differs from the default value used if the option isn’t given at all, will be used.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#argument ⇒ String
readonly
The name of the argument to the receiver.
Attributes inherited from Flag
#default, #description, #long, #short
Instance Method Summary collapse
-
#initialize(short, long, argument, default, argument_default, description) {|?| ... } ⇒ Switch
constructor
A new instance of Switch.
Methods inherited from Flag
#ignored?, #name, #names, #process, #process_combined
Constructor Details
#initialize(short, long, argument, default, argument_default, description) {|?| ... } ⇒ Switch
Returns a new instance of Switch.
20 21 22 23 24 25 |
# File 'lib/ame-1.0/switch.rb', line 20 def initialize(short, long, argument, default, argument_default, description, &validate) @argument = argument.upcase @type = Ame::Types[[argument_default, default, String].reject(&:nil?).first] @argument_default = @type.respond_to?(:default) ? @type.default : argument_default super short, long, default, description, &validate end |
Instance Attribute Details
#argument ⇒ String (readonly)
Returns The name of the argument to the receiver.
28 29 30 |
# File 'lib/ame-1.0/switch.rb', line 28 def argument @argument end |