Module: GroupOptionParser
- Included in:
- ExtOptParse
- Defined in:
- lib/group_option_parser.rb
Overview
Add grouping to Ruby’s ‘OptionParser`
Instance Method Summary collapse
-
#group(name) {|_self| ... } ⇒ Object
run block in context of a group, if group does not exist it’s created.
-
#remove(name) ⇒ Object
allows removing last or group by ‘name`.
-
#top ⇒ Object
changes the target of all functions to be set by ‘group`.
Instance Method Details
#group(name) {|_self| ... } ⇒ Object
run block in context of a group, if group does not exist it’s created
42 43 44 45 46 |
# File 'lib/group_option_parser.rb', line 42 def group(name, &_block) self.current_top = group_index(name) yield self self.current_top = TOP_INDEX end |
#remove(name) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/group_option_parser.rb', line 32 def remove(name=nil) if name remove_group(name) else remove_last end end |
#top ⇒ Object
changes the target of all functions to be set by ‘group`
26 27 28 |
# File 'lib/group_option_parser.rb', line 26 def top @stack[current_top] end |