Class: Bundesstrasse::Context
- Inherits:
-
Object
- Object
- Bundesstrasse::Context
show all
- Includes:
- Errors
- Defined in:
- lib/bundesstrasse/context.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Errors
#errno, #error_check, #error_string
Constructor Details
#initialize(zmq_context) ⇒ Context
Returns a new instance of Context.
6
7
8
|
# File 'lib/bundesstrasse/context.rb', line 6
def initialize(zmq_context)
@zmq_context = zmq_context
end
|
Class Method Details
.create(options = {}) ⇒ Object
33
34
35
|
# File 'lib/bundesstrasse/context.rb', line 33
def self.create(options={})
new ZMQ::Context.create(options[:io_threads] || 1)
end
|
Instance Method Details
#socket(socket_type, options = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/bundesstrasse/context.rb', line 10
def socket(socket_type, options={})
raise ContextError, 'Context terminated' if terminated?
socket_type = translate_socket_type(socket_type)
zmq_socket = error_check { @zmq_context.socket(socket_type) }
case socket_type
when ZMQ::SUB, ZMQ::XSUB
SubSocket.new(zmq_socket, options)
else
Socket.new(zmq_socket, options)
end
rescue ZMQError => e
ContextError.raise_error(e)
end
|
#terminate! ⇒ Object
24
25
26
27
|
# File 'lib/bundesstrasse/context.rb', line 24
def terminate!
@zmq_context.terminate
true
end
|
#terminated? ⇒ Boolean
29
30
31
|
# File 'lib/bundesstrasse/context.rb', line 29
def terminated?
@zmq_context.context.nil?
end
|