Class: SelectRailsLog::CommandLineOptions
- Defined in:
- lib/select_rails_log/command_line_options.rb
Class Attribute Summary collapse
-
.initializers ⇒ Object
readonly
Returns the value of attribute initializers.
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #add_option(ext_name, opt_name, *optparse_args, default: nil) ⇒ Object
- #extensions(group) ⇒ Object
-
#initialize ⇒ CommandLineOptions
constructor
A new instance of CommandLineOptions.
- #parse!(argv) ⇒ Object
- #register(ext_name) ⇒ Object
Methods inherited from Options
Constructor Details
#initialize ⇒ CommandLineOptions
Returns a new instance of CommandLineOptions.
14 15 16 17 18 19 20 21 |
# File 'lib/select_rails_log/command_line_options.rb', line 14 def initialize super @parser = OptionParser.new @parser. += " [logfiles...]" @extensions = {} @extension_groups = {} setup end |
Class Attribute Details
.initializers ⇒ Object (readonly)
Returns the value of attribute initializers.
9 10 11 |
# File 'lib/select_rails_log/command_line_options.rb', line 9 def initializers @initializers end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
12 13 14 |
# File 'lib/select_rails_log/command_line_options.rb', line 12 def parser @parser end |
Instance Method Details
#add_option(ext_name, opt_name, *optparse_args, default: nil) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/select_rails_log/command_line_options.rb', line 33 def add_option(ext_name, opt_name, *optparse_args, default: nil) self[ext_name][opt_name] = nil parser.on(*optparse_args) do |value| value = default if value.nil? self[ext_name][opt_name] = value end end |
#extensions(group) ⇒ Object
42 43 44 |
# File 'lib/select_rails_log/command_line_options.rb', line 42 def extensions(group) @extension_groups[group] end |
#parse!(argv) ⇒ Object
23 24 25 |
# File 'lib/select_rails_log/command_line_options.rb', line 23 def parse!(argv) parser.parse!(argv) end |
#register(ext_name) ⇒ Object
27 28 29 30 31 |
# File 'lib/select_rails_log/command_line_options.rb', line 27 def register(ext_name) return if key?(ext_name) self[ext_name] = Options.new end |