Class: Moister::OptionParserExtra
- Inherits:
-
OptionParser
- Object
- OptionParser
- Moister::OptionParserExtra
- Defined in:
- lib/moister.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ OptionParserExtra
constructor
A new instance of OptionParserExtra.
-
#on(*opts, &block) ⇒ Object
like OptionParser#on but if a block is not supplied the last argument (which should be a string) is used as a hash key to store that value within @config.
Constructor Details
#initialize(config = {}) ⇒ OptionParserExtra
Returns a new instance of OptionParserExtra.
8 9 10 11 |
# File 'lib/moister.rb', line 8 def initialize(config = {}) @config = config super end |
Instance Method Details
#on(*opts, &block) ⇒ Object
like OptionParser#on but if a block is not supplied the last argument (which should be a string) is used as a hash key to store that value within @config.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/moister.rb', line 15 def on *opts, &block if block super *opts, &block else key = opts.pop super *opts do |val| @config[key] = val end end end |