Class: Ame::Multioption
- Defined in:
- lib/ame-1.0/multioption.rb
Overview
Represents an option to a Method that takes an argument that can be given any number of times. If an explicit (‘=’-separated) argument is given, it’ll be used, otherwise the following argument will be used.
Instance Attribute Summary
Attributes inherited from Switch
Attributes inherited from Flag
#default, #description, #long, #short
Instance Method Summary collapse
-
#ignored? ⇒ Boolean
True if the receiver hasn’t been asked to process any options yet.
-
#initialize(short, long, argument, type, description) {|?| ... } ⇒ Multioption
constructor
A new instance of Multioption.
-
#process(options, arguments, name, explicit) ⇒ Object
Invokes super and adds it to an Array added to OPTIONS before returning it.
Methods inherited from Option
Methods inherited from Flag
#name, #names, #process_combined
Constructor Details
#initialize(short, long, argument, type, description) {|?| ... } ⇒ Multioption
Returns a new instance of Multioption.
15 16 17 18 19 |
# File 'lib/ame-1.0/multioption.rb', line 15 def initialize(short, long, argument, type, description, &validate) super short, long, argument, nil, description, &validate @type = Ame::Types[type] @ignored = true end |
Instance Method Details
#ignored? ⇒ Boolean
Returns True if the receiver hasn’t been asked to process any options yet.
33 34 35 |
# File 'lib/ame-1.0/multioption.rb', line 33 def ignored? @ignored end |
#process(options, arguments, name, explicit) ⇒ Object
Invokes super and adds it to an Array added to OPTIONS before returning it.
27 28 29 30 |
# File 'lib/ame-1.0/multioption.rb', line 27 def process(, arguments, name, explicit) @ignored = false ([self.name] ||= []) << super end |