Class: Buster::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/buster/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Context

Returns a new instance of Context.



6
7
8
9
# File 'lib/buster/context.rb', line 6

def initialize(context)
  @context = context
  @sockets = []
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



4
5
6
# File 'lib/buster/context.rb', line 4

def context
  @context
end

Instance Method Details

#socket(type) ⇒ Object



11
12
13
14
15
# File 'lib/buster/context.rb', line 11

def socket(type)
  socket = @context.socket(type)
  @sockets << socket
  socket
end

#terminateObject



17
18
19
20
21
22
23
# File 'lib/buster/context.rb', line 17

def terminate
  @sockets.reverse.each do |s|
    s.setsockopt(ZMQ::LINGER, 0)
    s.close
  end
  @context.terminate
end