Sha256: 5cc36c25c35351181fec452ae9f006d76e714a077fb3bc7f0de7ef83d2d8fbfb

Contents?: true

Size: 631 Bytes

Versions: 6

Compression:

Stored size: 631 Bytes

Contents

module ZMQ

  class Device
    attr_reader :device

    def self.create(device_type, frontend, backend)
      dev = nil
      begin
        dev = new(device_type, frontend, backend)
      rescue ArgumentError
        dev = nil
      end

      dev
    end

    def initialize(device_type, frontend, backend)
      [["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_device(device_type, frontend.socket, backend.socket)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ffi-rzmq-1.0.3 lib/ffi-rzmq/device.rb
ffi-rzmq-1.0.2 lib/ffi-rzmq/device.rb
ffi-rzmq-1.0.1 lib/ffi-rzmq/device.rb
ffi-rzmq-1.0.0 lib/ffi-rzmq/device.rb
ffi-rzmq-0.9.7 lib/ffi-rzmq/device.rb
ffi-rzmq-0.9.6 lib/ffi-rzmq/device.rb