Class: DocoptNG::Argument
- Inherits:
-
ChildPattern
- Object
- Pattern
- ChildPattern
- DocoptNG::Argument
- Defined in:
- lib/docopt_ng/argument.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ChildPattern
Attributes inherited from Pattern
Class Method Summary collapse
-
.parse(class_, source) ⇒ Object
TODO: This does not seem to be used, and can be the solution to having default values for arguments.
Instance Method Summary collapse
Methods inherited from ChildPattern
#flat, #initialize, #inspect, #match
Methods inherited from Pattern
#==, #dump, #either, #fix, #fix_identities, #fix_repeating_arguments, #to_str
Constructor Details
This class inherits a constructor from DocoptNG::ChildPattern
Class Method Details
.parse(class_, source) ⇒ Object
TODO: This does not seem to be used, and can be the solution to having
default values for arguments
17 18 19 20 21 |
# File 'lib/docopt_ng/argument.rb', line 17 def self.parse(class_, source) name = /(<\S*?>)/.match(source)[0] value = /\[default: (.*)\]/i.match(source) class_.new(name, (value ? value[0] : nil)) end |