<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>parse (GameObject)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> <pre><span class="ruby-comment cmt"># File lib/core/gameobject.rb, line 117</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">m</span>) <span class="ruby-comment cmt"># match legal command</span> <span class="ruby-identifier">m</span><span class="ruby-operator">=~</span><span class="ruby-regexp re">/([A-Za-z0-9_@?"'#!]+)(.*)/</span> <span class="ruby-identifier">cmd</span>=<span class="ruby-identifier">$1</span> <span class="ruby-identifier">arg</span>=<span class="ruby-identifier">$2</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">strip!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span> <span class="ruby-comment cmt"># look for a command from our table for objects</span> <span class="ruby-identifier">c</span> = <span class="ruby-identifier">world</span>.<span class="ruby-identifier">ocmds</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">cmd</span>) <span class="ruby-comment cmt"># there are three possibilities here</span> <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt"># no commands found</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span> <span class="ruby-comment cmt"># command found</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">c</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">arg</span>) <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># ambiguous command - tell luser about them.</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span></pre> </body> </html>