Files

ZMQ

Public Class Methods

Frame(data = nil) click to toggle source

Sugaring for creating new ZMQ frames

ZMQ::Frame(“frame”) => ZMQ::Frame

# File lib/zmq.rb, line 18
def self.Frame(data = nil)
  ZMQ::Frame.new(data)
end
Message(*parts) click to toggle source

Sugaring for creating new ZMQ messages

ZMQ::Message(“one”, “two”, “three”) => ZMQ::Message

# File lib/zmq.rb, line 26
def self.Message(*parts)
  m = ZMQ::Message.new
  parts.each{|p| m.addstr(p) }
  m
end
Pollitem(pollable, events = nil) click to toggle source

Sugaring for creating new poll items

ZMQ::Pollitem(STDIN, ZMQ::POLLIN) => ZMQ::Pollitem

# File lib/zmq.rb, line 36
def self.Pollitem(pollable, events = nil)
  ZMQ::Pollitem.new(pollable, events)
end
context() click to toggle source

Returns the ZMQ context for this process, if any

# File lib/zmq.rb, line 42
def self.context
  @__zmq_ctx_process[Process.pid]
end
error => ZMQ::Error click to toggle source
Returns the last known ZMQ error (if any) as a ZMQ::Error instance.

Examples

ZMQ.error    =>  ZMQ::Error or nil
static VALUE rb_czmq_m_error(ZMQ_UNUSED VALUE obj)
{
    int err;
    err = zmq_errno();
    if (err == 0) return Qnil;
    return rb_exc_new2(rb_eZmqError, zmq_strerror(zmq_errno()));
}
interrupted? => boolean click to toggle source
Returns true if the process was interrupted by signal.

Examples

ZMQ.interrupted?    =>  boolean
static VALUE rb_czmq_m_interrupted_p(ZMQ_UNUSED VALUE obj)
{
    return (zctx_interrupted == TRUE) ? Qtrue : Qfalse;
}
log("msg") => nil click to toggle source
Logs a timestamped message to stdout.

Examples

ZMQ.log("msg")    =>  nil # 11-12-06 21:20:55 msg
static VALUE rb_czmq_m_log(ZMQ_UNUSED VALUE obj, VALUE msg)
{
    Check_Type(msg, T_STRING);
    zclock_log(StringValueCStr(msg));
    return Qnil;
}
loop() click to toggle source

Higher level loop API.

XXX: Handle cases where context is nil

# File lib/zmq.rb, line 50
def self.loop
  @loop ||= ZMQ::Loop.new(context)
end
now => Fixnum click to toggle source
Returns a current timestamp as a Fixnum

Examples

ZMQ.now    =>  1323206405148
static VALUE rb_czmq_m_now(ZMQ_UNUSED VALUE obj)
{
    return INT2NUM(zclock_time());
}
select(read = [], write = [], error = [], timeout = nil) click to toggle source

API sugaring: IO.select compatible API, but for ZMQ sockets.

# File lib/zmq.rb, line 56
def self.select(read = [], write = [], error = [], timeout = nil)
  poller = ZMQ::Poller.new
  read.each{|s| poller.register_readable(s) } if read
  write.each{|s| poller.register_writable(s) } if write
  ready = poller.poll(timeout)
  [poller.readables, poller.writables, []] if ready
end
version => Array click to toggle source
Returns the libzmq version linked against.

Examples

ZMQ.version    =>  [2,1,11]
static VALUE rb_czmq_m_version(ZMQ_UNUSED VALUE obj)
{
    int major, minor, patch;
    zmq_version(&major, &minor, &patch);
    return rb_ary_new3(3, INT2NUM(major), INT2NUM(minor), INT2NUM(patch));
}

[Validate]

Generated with the Darkfish Rdoc Generator 2.