Class: Lab42::Options::Parser
- Inherits:
-
Object
- Object
- Lab42::Options::Parser
- Defined in:
- lib/lab42/options/parser.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#defaults ⇒ Object
Returns the value of attribute defaults.
-
#kwds ⇒ Object
Returns the value of attribute kwds.
-
#positionals ⇒ Object
Returns the value of attribute positionals.
-
#yaml_file ⇒ Object
Returns the value of attribute yaml_file.
Instance Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/lab42/options/parser.rb', line 9 def data @data end |
#defaults ⇒ Object
Returns the value of attribute defaults.
9 10 11 |
# File 'lib/lab42/options/parser.rb', line 9 def defaults @defaults end |
#kwds ⇒ Object
Returns the value of attribute kwds.
9 10 11 |
# File 'lib/lab42/options/parser.rb', line 9 def kwds @kwds end |
#positionals ⇒ Object
Returns the value of attribute positionals.
9 10 11 |
# File 'lib/lab42/options/parser.rb', line 9 def positionals @positionals end |
#yaml_file ⇒ Object
Returns the value of attribute yaml_file.
9 10 11 |
# File 'lib/lab42/options/parser.rb', line 9 def yaml_file @yaml_file end |
Instance Method Details
#errors ⇒ Object
24 |
# File 'lib/lab42/options/parser.rb', line 24 def errors; @errors.dup end |
#parse(option, args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lab42/options/parser.rb', line 11 def parse option, args self.yaml_file = option.yaml_file self.data = {to_a: args} parse_all args # read_yaml file might need the args parsed defaults = read_yaml_file || option.defaults merged = defaults.merge kwds merged = extend_values merged result = data.merge kwds: OpenStruct.new( merged ), args: positionals check_for_errors option, args if option.strict_mode result end |