Class: Trace2::OptionParser
- Inherits:
-
OptionParser
- Object
- OptionParser
- Trace2::OptionParser
- Defined in:
- lib/trace2/option_parser.rb
Overview
Class that parses the options that will be used by trace2
Instance Attribute Summary collapse
-
#options_keys ⇒ Object
readonly
Returns the value of attribute options_keys.
Instance Method Summary collapse
- #add_option(short: nil, long: nil, description: []) ⇒ Object
-
#initialize(banner = nil, width = 32, indent = ' ' * 4) ⇒ OptionParser
constructor
A new instance of OptionParser.
- #split_executables(args) ⇒ Object
Constructor Details
#initialize(banner = nil, width = 32, indent = ' ' * 4) ⇒ OptionParser
Returns a new instance of OptionParser.
11 12 13 14 |
# File 'lib/trace2/option_parser.rb', line 11 def initialize( = nil, width = 32, indent = ' ' * 4) @options_keys = {} super(, width, indent) end |
Instance Attribute Details
#options_keys ⇒ Object (readonly)
Returns the value of attribute options_keys.
9 10 11 |
# File 'lib/trace2/option_parser.rb', line 9 def @options_keys end |
Instance Method Details
#add_option(short: nil, long: nil, description: []) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/trace2/option_parser.rb', line 16 def add_option(short: nil, long: nil, description: []) @options_keys.merge!(**option_hash(short), **option_hash(long)) = [short, long].compact on(*, *description) do |option_value| yield option_value end end |
#split_executables(args) ⇒ Object
24 25 26 27 28 |
# File 'lib/trace2/option_parser.rb', line 24 def split_executables(args) second_executable = second_executable_arguments(args) [args.shift(args.length - second_executable.length), second_executable] end |