doc/EZMQ/Subscriber.html in ezmq-0.3.1 vs doc/EZMQ/Subscriber.html in ezmq-0.3.2

- old
+ new

@@ -94,11 +94,11 @@ <dt class="r2 last">Defined in:</dt> - <dd class="r2 last">lib/ezmq.rb</dd> + <dd class="r2 last">lib/ezmq/subscribe.rb</dd> </dl> <div class="clear"></div> <h2>Overview</h2><div class="docstring"> @@ -191,10 +191,58 @@ <li class="public "> <span class="summary_signature"> + <a href="#listen-instance_method" title="#listen (instance method)">- (void) <strong>listen</strong> {|message, topic| ... }</a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>By default, waits for a message and prints it to STDOUT.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#receive-instance_method" title="#receive (instance method)">- (Object) <strong>receive</strong>(**options) {|message, topic| ... }</a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Receive a message from the socket.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#subscribe-instance_method" title="#subscribe (instance method)">- (Boolean) <strong>subscribe</strong>(topic) </a> </span> @@ -249,11 +297,11 @@ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3> - <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#listen-instance_method" title="EZMQ::Socket#listen (method)">#listen</a></span>, <span class='object_link'><a href="Socket.html#receive-instance_method" title="EZMQ::Socket#receive (method)">#receive</a></span>, <span class='object_link'><a href="Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span></p> + <p class="inherited"><span class='object_link'><a href="Socket.html#bind-instance_method" title="EZMQ::Socket#bind (method)">#bind</a></span>, <span class='object_link'><a href="Socket.html#connect-instance_method" title="EZMQ::Socket#connect (method)">#connect</a></span>, <span class='object_link'><a href="Socket.html#send-instance_method" title="EZMQ::Socket#send (method)">#send</a></span></p> <div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> <h3 class="signature first" id="initialize-instance_method"> @@ -336,17 +384,17 @@ <tr> <td> <pre class="lines"> -232 -233 -234 -235</pre> +19 +20 +21 +22</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 232</span> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 19</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='kw'>super</span> <span class='symbol'>:connect</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>SUB</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='id identifier rubyid_subscribe'>subscribe</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:topic</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:topic</span><span class='rbracket'>]</span> <span class='kw'>end</span></pre> @@ -386,16 +434,16 @@ <tr> <td> <pre class="lines"> -220 -221 -222</pre> +7 +8 +9</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 220</span> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 7</span> <span class='kw'>def</span> <span class='id identifier rubyid_action'>action</span> <span class='ivar'>@action</span> <span class='kw'>end</span></pre> </td> @@ -409,12 +457,304 @@ <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="subscribe-instance_method"> + <h3 class="signature first" id="listen-instance_method"> + - (<tt>void</tt>) <strong>listen</strong> {|message, topic| ... } + + + + + +</h3><div class="docstring"> + <div class="discussion"> + <p class="note returns_void">This method returns an undefined value.</p> +<p>By default, waits for a message and prints it to STDOUT.</p> + + + </div> +</div> +<div class="tags"> + +<p class="tag_title">Yields:</p> +<ul class="yield"> + + <li> + + + <span class='type'>(<tt>message</tt>, <tt>topic</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>passes the message body and topic to the block.</p> +</div> + + </li> + +</ul> +<p class="tag_title">Yield Parameters:</p> +<ul class="yieldparam"> + + <li> + + <span class='name'>message</span> + + + <span class='type'>(<tt>String</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>the message received.</p> +</div> + + </li> + + <li> + + <span class='name'>topic</span> + + + <span class='type'>(<tt>String</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>the topic of the message.</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +59 +60 +61 +62 +63 +64 +65 +66 +67 +68</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 59</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_listen'>listen</span> + <span class='id identifier rubyid_loop'>loop</span> <span class='kw'>do</span> + <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span> + <span class='kw'>yield</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_receive'>receive</span><span class='rparen'>)</span> + <span class='kw'>else</span> + <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_topic'>topic</span> <span class='op'>=</span> <span class='id identifier rubyid_receive'>receive</span> + <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_topic'>topic</span> <span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_message'>message</span> <span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> + <span class='kw'>end</span> + <span class='kw'>end</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="receive-instance_method"> + + - (<tt>Object</tt>) <strong>receive</strong>(**options) {|message, topic| ... } + + + + + +</h3><div class="docstring"> + <div class="discussion"> + + <div class="note notetag"> + <strong>Note:</strong> + <div class='inline'> +<p>This method blocks until a message arrives.</p> +</div> + </div> + + +<p>Receive a message from the socket.</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> +<ul class="param"> + + <li> + + <span class='name'>options</span> + + + <span class='type'>(<tt>Hash</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>optional parameters.</p> +</div> + + </li> + +</ul> + + + + + <p class="tag_title">Options Hash (<tt>**options</tt>):</p> + <ul class="option"> + + <li> + <span class="name">decode</span> + <span class="type">(<tt>lambda</tt>)</span> + <span class="default"> + + </span> + + &mdash; <div class='inline'> +<p>how to decode the message.</p> +</div> + + </li> + + </ul> + + +<p class="tag_title">Yields:</p> +<ul class="yield"> + + <li> + + + <span class='type'>(<tt>message</tt>, <tt>topic</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>passes the message body and topic to the block.</p> +</div> + + </li> + +</ul> +<p class="tag_title">Yield Parameters:</p> +<ul class="yieldparam"> + + <li> + + <span class='name'>message</span> + + + <span class='type'>(<tt>Object</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>the message received (decoded).</p> +</div> + + </li> + + <li> + + <span class='name'>topic</span> + + + <span class='type'>(<tt>String</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>the topic of the message.</p> +</div> + + </li> + +</ul> +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Object</tt>)</span> + + + + &mdash; + <div class='inline'> +<p>the message received (decoded).</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 37</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_receive'>receive</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> + <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span> + <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_recv_string'>recv_string</span> <span class='id identifier rubyid_message'>message</span> + + <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(?&lt;topic&gt;[^\ ]*)\ (?&lt;body&gt;.*)</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> + + <span class='id identifier rubyid_decoded'>decoded</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:decode</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='ivar'>@decode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='id identifier rubyid_message'>message</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>body</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> + <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span> + <span class='kw'>yield</span> <span class='id identifier rubyid_decoded'>decoded</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>topic</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> + <span class='kw'>else</span> + <span class='lbracket'>[</span><span class='id identifier rubyid_decoded'>decoded</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>topic</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rbracket'>]</span> + <span class='kw'>end</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="subscribe-instance_method"> + - (<tt>Boolean</tt>) <strong>subscribe</strong>(topic) @@ -485,16 +825,16 @@ <tr> <td> <pre class="lines"> -248 -249 -250</pre> +81 +82 +83</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 248</span> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 81</span> <span class='kw'>def</span> <span class='id identifier rubyid_subscribe'>subscribe</span><span class='lparen'>(</span><span class='id identifier rubyid_topic'>topic</span><span class='rparen'>)</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_setsockopt'>setsockopt</span><span class='lparen'>(</span><span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>SUBSCRIBE</span><span class='comma'>,</span> <span class='id identifier rubyid_topic'>topic</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>0</span> <span class='kw'>end</span></pre> </td> @@ -565,16 +905,16 @@ <tr> <td> <pre class="lines"> -259 -260 -261</pre> +92 +93 +94</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 259</span> + <pre class="code"><span class="info file"># File 'lib/ezmq/subscribe.rb', line 92</span> <span class='kw'>def</span> <span class='id identifier rubyid_unsubscribe'>unsubscribe</span><span class='lparen'>(</span><span class='id identifier rubyid_topic'>topic</span><span class='rparen'>)</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_setsockopt'>setsockopt</span><span class='lparen'>(</span><span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>UNSUBSCRIBE</span><span class='comma'>,</span> <span class='id identifier rubyid_topic'>topic</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>0</span> <span class='kw'>end</span></pre> </td> @@ -585,10 +925,10 @@ </div> </div> <div id="footer"> - Generated on Sun Jan 11 14:20:10 2015 by + Generated on Tue Jan 20 23:17:35 2015 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.8.7.6 (ruby-2.0.0). </div> </body> \ No newline at end of file