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
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
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
Returns the ZMQ context for this process, if any
# File lib/zmq.rb, line 42 def self.context @__zmq_ctx_process[Process.pid] end
Returns the last known ZMQ error (if any) as a ZMQ::Error instance.
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())); }
Returns true if the process was interrupted by signal.
ZMQ.interrupted? => boolean
static VALUE rb_czmq_m_interrupted_p(ZMQ_UNUSED VALUE obj) { return (zctx_interrupted == TRUE) ? Qtrue : Qfalse; }
Logs a timestamped message to stdout.
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; }
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
Returns a current timestamp as a Fixnum
ZMQ.now => 1323206405148
static VALUE rb_czmq_m_now(ZMQ_UNUSED VALUE obj) { return INT2NUM(zclock_time()); }
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
Returns the libzmq version linked against.
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)); }
Generated with the Darkfish Rdoc Generator 2.