Class: Raph::Parser::BaseParser
- Inherits:
-
Object
- Object
- Raph::Parser::BaseParser
- Defined in:
- lib/raph/parser/base_parser.rb
Overview
Base class for all argument parsers.
You can create a custom parser by subclassing
Raph::Parser::BaseParser and overriding some methods,
or by implementing all the methods by duck typing.
Direct Known Subclasses
Instance Method Summary collapse
-
#id ⇒ Object
Parser unique id.
-
#parse(args) ⇒ Object
Parses arguments and returns results of parsing.
Instance Method Details
#id ⇒ Object
Parser unique id. If parser class name follows a convention NameParser then it's id will be automatically determined as it's name in snake case plus suffix 's'
Example: FlagParser.new.id # => :flags FileParser.new.id # => :files BaseArgumentParser.new.id # => :base_arguments
19 20 21 22 23 |
# File 'lib/raph/parser/base_parser.rb', line 19 def id name = class_name.gsub(/parser$/i, '') name << 's' # make it plural to_underscored_sym(name) end |
#parse(args) ⇒ Object
Parses arguments and returns results of parsing.
26 27 |
# File 'lib/raph/parser/base_parser.rb', line 26 def parse(args) end |