Class: ZMQ::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi-rzmq/device.rb

Direct Known Subclasses

Proxy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#deviceObject (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