Class: Acclaim::Option::Parser
- Inherits:
-
Object
- Object
- Acclaim::Option::Parser
- Includes:
- Regexp
- Defined in:
- lib/acclaim/option/parser.rb,
lib/acclaim/option/parser/error.rb,
lib/acclaim/option/parser/regexp.rb
Overview
Parses arrays of strings and returns an Options instance containing data.
Defined Under Namespace
Modules: Regexp Classes: Error
Constant Summary
Constants included from Regexp
Regexp::ARGUMENT_SEPARATOR, Regexp::LONG_SWITCH, Regexp::MULTIPLE_SHORT_SWITCHES, Regexp::SHORT_SWITCH, Regexp::SWITCH, Regexp::SWITCH_PARAM_EQUALS
Instance Attribute Summary collapse
-
#argv ⇒ Object
The argument array to parse.
-
#options ⇒ Object
The options to be parsed.
Instance Method Summary collapse
-
#initialize(argv, options = nil) ⇒ Parser
constructor
Initializes a new parser, with the given argument array and set of options.
-
#parse! ⇒ Object
Parses the given argument array, looking for the given options and their arguments if any.
Constructor Details
#initialize(argv, options = nil) ⇒ Parser
Initializes a new parser, with the given argument array and set of options. If no option array is given, the argument array will be preprocessed only.
30 31 32 33 |
# File 'lib/acclaim/option/parser.rb', line 30 def initialize(argv, = nil) self.argv = argv || [] self. = || [] end |
Instance Attribute Details
#argv ⇒ Object
The argument array to parse.
22 23 24 |
# File 'lib/acclaim/option/parser.rb', line 22 def argv @argv end |
#options ⇒ Object
The options to be parsed.
25 26 27 |
# File 'lib/acclaim/option/parser.rb', line 25 def @options end |
Instance Method Details
#parse! ⇒ Object
Parsed options and their parameters will be removed from the argument array.
Parses the given argument array, looking for the given options and their arguments if any.
If no options were given, the argument array will be preprocessed only.
56 57 58 59 60 61 |
# File 'lib/acclaim/option/parser.rb', line 56 def parse! preprocess_argv! parse_values!.tap do end end |