Class: CmdParse::ParserWrapper
- Inherits:
-
Object
- Object
- CmdParse::ParserWrapper
- Defined in:
- lib/module_cmdparse/cmdparse.rb
Overview
Base class for all parser wrappers.
Direct Known Subclasses
Instance Method Summary collapse
-
#instance {|@instance| ... } ⇒ Object
Returns the parser instance for the object and, if a block is a given, yields the instance.
-
#order(args) ⇒ Object
Parses the arguments in order, i.e.
-
#permute(args) ⇒ Object
Permutes the arguments so that all options anywhere on the command line are parsed and the remaining non-options are returned.
-
#summarize ⇒ Object
Returns a summary string of the options.
Instance Method Details
#instance {|@instance| ... } ⇒ Object
Returns the parser instance for the object and, if a block is a given, yields the instance.
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.
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.
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 |
#summarize ⇒ Object
Returns a summary string of the options.
102 103 104 |
# File 'lib/module_cmdparse/cmdparse.rb', line 102 def summarize "" end |