Class: Raq::Runner
- Inherits:
-
Object
- Object
- Raq::Runner
- Defined in:
- lib/raq/runner.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#connection_options ⇒ Object
readonly
Returns the value of attribute connection_options.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #parse! ⇒ Object
- #parser ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 |
# File 'lib/raq/runner.rb', line 9 def initialize(argv) @argv = argv = {} parse! end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/raq/runner.rb', line 6 def command @command end |
#connection_options ⇒ Object (readonly)
Returns the value of attribute connection_options.
7 8 9 |
# File 'lib/raq/runner.rb', line 7 def end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/raq/runner.rb', line 5 def end |
Instance Method Details
#parse! ⇒ Object
31 32 33 34 35 |
# File 'lib/raq/runner.rb', line 31 def parse! parser.parse! @argv @command = @argv.shift = .reject {|k,v| [:queue, :type].include?(k) } end |
#parser ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/raq/runner.rb', line 17 def parser @parser ||= OptionParser.new do |opts| opts.on("-H", "--host HOST", "AMQP HOST address (default: #{@options[:host]}") { |host| [:host] = host } opts.on("-p", "--port PORT", "AMQP PORT") { |port| [:port] = port.to_i } opts.on("-q", "--queue QUEUE","AMQP Queue to use") { |queue| [:queue] = queue } opts.on("-u", "--user USER","AMQP User to connect as") { |user| [:user] = user } opts.on("-t", "--type TYPE","AMQP message type") { |type| [:type] = type } opts.on("-r", "--require LIBRARY","Require the provided library before starting") { |lib| require lib } # ... and on end end |