Class: Clive::Arguments::Parser
- Inherits:
-
Object
- Object
- Clive::Arguments::Parser
- Defined in:
- lib/clive/arguments/parser.rb
Defined Under Namespace
Classes: InvalidArgumentStringError
Constant Summary collapse
- KEYS =
Valid key names for creating arguments passed to Option#initialize and standard names to map them to.
{ :arg => [:args], :type => [:types, :kind, :as], :match => [:matches], :within => [:withins, :in], :default => [:defaults], :constraint => [:constraints] }.inject({}) {|hsh, (k,v)| (v + [k]).each {|key| hsh[key] = k } hsh }
Instance Method Summary collapse
-
#initialize(opts) ⇒ Parser
constructor
A new instance of Parser.
-
#to_a ⇒ Array<Hash>
This turns the arguments string and other options into a nicely formatted hash.
- #to_args ⇒ Array<Argument>
Constructor Details
Instance Method Details
#to_a ⇒ Array<Hash>
This turns the arguments string and other options into a nicely formatted hash.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/clive/arguments/parser.rb', line 35 def to_a multiple = to_arrays(@opts.dup) args = split_into_hashes(multiple) if @opts.has_key?(:arg) # Parse the argument string and merge in previous options from +singles+. args = parse_args_string(args, @opts[:arg]) end infer_args(args) end |