class OptParseBuilder::ArgumentBundleBuilder

Yielded by OptParseBuilder.bundle_arguments to create an ArgumentBundle, a collection of arguments that can be treated as through it is one argument.

Public Instance Methods

add(argument = nil, &block) click to toggle source

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.

# 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