Class: GLI::OptionParserFactory
- Inherits:
-
Object
- Object
- GLI::OptionParserFactory
- Defined in:
- lib/gli/option_parser_factory.rb
Overview
Factory for creating an OptionParser based on app configuration and DSL calls
Instance Method Summary collapse
-
#initialize(flags, switches, accepts) ⇒ OptionParserFactory
constructor
Create an OptionParserFactory for the given flags, switches, and accepts.
-
#option_parser ⇒ Object
Return an option parser to parse the given flags, switches and accepts.
Constructor Details
#initialize(flags, switches, accepts) ⇒ OptionParserFactory
Create an OptionParserFactory for the given flags, switches, and accepts
6 7 8 9 10 |
# File 'lib/gli/option_parser_factory.rb', line 6 def initialize(flags,switches,accepts) @flags = flags @switches = switches @accepts = accepts end |
Instance Method Details
#option_parser ⇒ Object
Return an option parser to parse the given flags, switches and accepts
13 14 15 16 17 18 19 20 21 |
# File 'lib/gli/option_parser_factory.rb', line 13 def option_parser = {} option_parser = OptionParser.new do |opts| self.class.setup_accepts(opts,@accepts) self.class.(opts,@switches,) self.class.(opts,@flags,) end [option_parser,] end |