Class: Distribot::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/distribot/connector.rb

Direct Known Subclasses

BunnyConnector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amqp_url = 'amqp://localhost:5672') ⇒ Connector

Returns a new instance of Connector.



13
14
15
16
# File 'lib/distribot/connector.rb', line 13

def initialize(amqp_url = 'amqp://localhost:5672')
  self.amqp_url = amqp_url
  setup
end

Instance Attribute Details

#amqp_urlObject

Returns the value of attribute amqp_url.



12
13
14
# File 'lib/distribot/connector.rb', line 12

def amqp_url
  @amqp_url
end

#bunnyObject

Returns the value of attribute bunny.



12
13
14
# File 'lib/distribot/connector.rb', line 12

def bunny
  @bunny
end

#channelObject

Returns the value of attribute channel.



12
13
14
# File 'lib/distribot/connector.rb', line 12

def channel
  @channel
end

Instance Method Details

#loggerObject



26
27
28
# File 'lib/distribot/connector.rb', line 26

def logger
  Distribot.logger
end

#queuesObject



18
19
20
21
22
23
24
# File 'lib/distribot/connector.rb', line 18

def queues
  uri = URI.parse(amqp_url)
  uri.scheme = 'http'
  uri.port = '15672'.to_i
  uri.path = '/api/queues'
  uri.to_s.to_uri.get.deserialize.map { |x| x['name'] }
end