Class: OptParseBuilder::ArgumentBundleBuilder
- Inherits:
-
Object
- Object
- OptParseBuilder::ArgumentBundleBuilder
- Defined in:
- lib/opt_parse_builder/argument_bundle_builder.rb
Overview
Yielded by OptParseBuilder.bundle_arguments to create an ArgumentBundle, a collection of arguments that can be treated as through it is one argument.
Instance Method Summary collapse
-
#add(argument = nil, &block) ⇒ Object
Add an argument to the bundle.
-
#argument ⇒ Object
:nodoc:.
-
#initialize ⇒ ArgumentBundleBuilder
constructor
:nodoc:.
Constructor Details
#initialize ⇒ ArgumentBundleBuilder
:nodoc:
8 9 10 |
# File 'lib/opt_parse_builder/argument_bundle_builder.rb', line 8 def initialize # :nodoc: @argument_bundle = ArgumentBundle.new end |
Instance Method Details
#add(argument = nil, &block) ⇒ Object
Add an argument to the bundle. Takes either the argument to add, or yields an ArgumentBuilder which builds a new argument and adds it.
If adding an existing argument, that argument may itself be an ArgumentBundle.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/opt_parse_builder/argument_bundle_builder.rb', line 18 def add(argument = nil, &block) unless argument.nil? ^ block.nil? raise BuildError, "Need exactly 1 of arg and block" end if argument @argument_bundle << argument else @argument_bundle << OptParseBuilder.build_argument(&block) end end |
#argument ⇒ Object
:nodoc:
29 30 31 |
# File 'lib/opt_parse_builder/argument_bundle_builder.rb', line 29 def argument # :nodoc: @argument_bundle.simplify end |