Class: Postqueue::CLI::OptionsParser
- Inherits:
-
Object
- Object
- Postqueue::CLI::OptionsParser
- Defined in:
- lib/postqueue/cli/options_parser.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ OptionsParser
constructor
A new instance of OptionsParser.
- #parse_args ⇒ Object
Constructor Details
#initialize(argv) ⇒ OptionsParser
Returns a new instance of OptionsParser.
12 13 14 |
# File 'lib/postqueue/cli/options_parser.rb', line 12 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
10 11 12 |
# File 'lib/postqueue/cli/options_parser.rb', line 10 def argv @argv end |
Class Method Details
.parse_args(argv) ⇒ Object
6 7 8 |
# File 'lib/postqueue/cli/options_parser.rb', line 6 def self.parse_args(argv) new(argv).parse_args end |
Instance Method Details
#parse_args ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/postqueue/cli/options_parser.rb', line 16 def parse_args require "optparse" = OpenStruct.new .sub_command = argv.shift || "stats" unless %w(stats peek enqueue run process).include?(.sub_command) usage! end case .sub_command when "enqueue" .op = next_arg! .entity_ids = next_arg!.split(",").map { |s| Integer(s) } end end |