Class: CmdParse::ParserWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/module_cmdparse/cmdparse.rb

Overview

Base class for all parser wrappers.

Direct Known Subclasses

OptionParserWrapper

Instance Method Summary collapse

Instance Method Details

#instance {|@instance| ... } ⇒ Object

Returns the parser instance for the object and, if a block is a given, yields the instance.

Yields:



82
83
84
85
# File 'lib/module_cmdparse/cmdparse.rb', line 82

def instance
    yield @instance if block_given?
    @instance
end

#order(args) ⇒ Object

Parses the arguments in order, i.e. stops at the first non-option argument, and returns all remaining arguments.

Raises:



89
90
91
92
# File 'lib/module_cmdparse/cmdparse.rb', line 89

def order( args )
    raise InvalidOptionError.new( args[0] ) if args[0] =~ /^-/
    args
end

#permute(args) ⇒ Object

Permutes the arguments so that all options anywhere on the command line are parsed and the remaining non-options are returned.

Raises:



96
97
98
99
# File 'lib/module_cmdparse/cmdparse.rb', line 96

def permute( args )
    raise InvalidOptionError.new( args[0] ) if args.any? {|a| a =~ /^-/}
    args
end

#summarizeObject

Returns a summary string of the options.



102
103
104
# File 'lib/module_cmdparse/cmdparse.rb', line 102

def summarize
    ""
end