Class: ZMQ::Device
- Inherits:
-
Object
- Object
- ZMQ::Device
- Defined in:
- lib/ffi-rzmq/device.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(frontend, backend, capture = nil) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(frontend, backend, capture = nil) ⇒ Device
Returns a new instance of Device.
17 18 19 20 21 22 23 24 25 |
# File 'lib/ffi-rzmq/device.rb', line 17 def initialize(frontend, backend, capture=nil) [["frontend", frontend], ["backend", backend]].each do |name, socket| unless socket.is_a?(ZMQ::Socket) raise ArgumentError, "Expected a ZMQ::Socket, not a #{socket.class} as the #{name}" end end LibZMQ.zmq_proxy(frontend.socket, backend.socket, capture ? capture.socket : nil) end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
4 5 6 |
# File 'lib/ffi-rzmq/device.rb', line 4 def device @device end |
Class Method Details
.create(frontend, backend, capture = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ffi-rzmq/device.rb', line 6 def self.create(frontend, backend, capture=nil) dev = nil begin dev = new(frontend, backend, capture) rescue ArgumentError dev = nil end dev end |