html/classes/MethodicHash.html in eymiha_util-0.1.2 vs html/classes/MethodicHash.html in eymiha_util-0.1.3

- old
+ new

@@ -1,198 +1,200 @@ -<?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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>Class: MethodicHash</title> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> - <meta http-equiv="Content-Script-Type" content="text/javascript" /> - <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" /> - <script type="text/javascript"> - // <![CDATA[ - - function popupCode( url ) { - window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") - } - - function toggleCode( id ) { - if ( document.getElementById ) - elem = document.getElementById( id ); - else if ( document.all ) - elem = eval( "document.all." + id ); - else - return false; - - elemStyle = elem.style; - - if ( elemStyle.display != "block" ) { - elemStyle.display = "block" - } else { - elemStyle.display = "none" - } - - return true; - } - - // Make codeblocks hidden by default - document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) - - // ]]> - </script> - -</head> -<body> - - - - <div id="classHeader"> - <table class="header-table"> - <tr class="top-aligned-row"> - <td><strong>Class</strong></td> - <td class="class-name-in-header">MethodicHash</td> - </tr> - <tr class="top-aligned-row"> - <td><strong>In:</strong></td> - <td> - <a href="../files/lib/methodic_hash_rb.html"> - lib/methodic_hash.rb - </a> - <br /> - </td> - </tr> - - <tr class="top-aligned-row"> - <td><strong>Parent:</strong></td> - <td> - Hash - </td> - </tr> - </table> - </div> - <!-- banner header --> - - <div id="bodyContent"> - - - - <div id="contextContent"> - - <div id="description"> - <p> -The <a href="MethodicHash.html">MethodicHash</a> is some <a -href="MethodicHash.html#M000005">method_missing</a> magic that tries to -lookup values when keys are passed in as method calls. For instance, if -</p> -<pre> - mh = MethodicHash.new - mh['four'] = 'iv' - mh[:seven] = 'vii' -</pre> -<p> -then -</p> -<pre> - mh['four'] ---&gt; 'iv' - mh[:four] ---&gt; 'iv' - mh.four ---&gt; 'iv' -</pre> -<p> -and -</p> -<pre> - mh['seven'] ---&gt; 'vii' - mh[:seven] ---&gt; 'vii' - mh.seven ---&gt; 'vii' -</pre> -<p> -This allows access to simply declared facts to be embedded in Ruby code and -leverages the possibility of hashing procs. -</p> -<p> -Note that if the hash uses anything but strings or symbols as keys, the -magic stands a good chance of failing, raising an error or acting in a -bizarre manner. -</p> - - </div> - - - </div> - - <div id="method-list"> - <h3 class="section-bar">Methods</h3> - - <div class="name-list"> - <a href="#M000004">[]</a>&nbsp;&nbsp; - <a href="#M000005">method_missing</a>&nbsp;&nbsp; - </div> - </div> - - </div> - - - <!-- if includes --> - - <div id="section"> - - - - - - - - - <!-- if method_list --> - <div id="methods"> - <h3 class="section-bar">Public Instance methods</h3> - - <div id="method-M000004" class="method-detail"> - <a name="M000004"></a> - - <div class="method-heading"> - <a href="MethodicHash.src/M000004.html" target="Code" class="method-signature" - onclick="popupCode('MethodicHash.src/M000004.html');return false;"> - <span class="method-name">[]</span><span class="method-args">(key)</span> - </a> - </div> - - <div class="method-description"> - <p> -Try to look up using a key directly, or if that fails as a string, or as a -symbol as last resort. If a symbol conversion doesn&#8217;t exists, rescue -with a nil. -</p> - </div> - </div> - - <div id="method-M000005" class="method-detail"> - <a name="M000005"></a> - - <div class="method-heading"> - <a href="MethodicHash.src/M000005.html" target="Code" class="method-signature" - onclick="popupCode('MethodicHash.src/M000005.html');return false;"> - <span class="method-name">method_missing</span><span class="method-args">(method,*args)</span> - </a> - </div> - - <div class="method-description"> - <p> -A missing method is assummed to be the value of a key. -</p> - </div> - </div> - - - </div> - - - </div> - - -<div id="validator-badges"> - <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> -</div> - -</body> +<?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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: MethodicHash</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">MethodicHash</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../files/lib/methodic_hash_rb.html"> + lib/methodic_hash.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Hash + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +The <a href="MethodicHash.html">MethodicHash</a> is some <a +href="MethodicHash.html#M000005">method_missing</a> magic that uses method +names as hash keys, so hash assignment and lookup appear to be attribute +writing and reading. For instance, if +</p> +<pre> + mh = MethodicHash.new + mh['four'] = 'iv' + mh[:seven] = 'vii' + mh.eighteen = 'xviii' +</pre> +<p> +then +</p> +<pre> + mh['four'] ---&gt; 'iv' + mh[:four] ---&gt; 'iv' + mh.four ---&gt; 'iv' + mh['seven'] ---&gt; 'vii' + mh[:seven] ---&gt; 'vii' + mh.seven ---&gt; 'vii' + mh['eighteen'] ---&gt; 'xviii' + mh[:eighteen] ---&gt; 'xviii' + mh.eighteen ---&gt; 'xviii' +</pre> +<p> +This allows access to simply declared facts to be embedded in Ruby code and +leverages the possibility of hashing procs. +</p> +<p> +Note that if the hash uses anything but strings or symbols as keys, the +magic stands a good chance of failing, raising an error or acting in a +bizarre manner. Note also that methods of the Hash cannot be used as +&#8216;attribute&#8217; names. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000004">[]</a>&nbsp;&nbsp; + <a href="#M000005">method_missing</a>&nbsp;&nbsp; + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000004" class="method-detail"> + <a name="M000004"></a> + + <div class="method-heading"> + <a href="MethodicHash.src/M000004.html" target="Code" class="method-signature" + onclick="popupCode('MethodicHash.src/M000004.html');return false;"> + <span class="method-name">[]</span><span class="method-args">(key)</span> + </a> + </div> + + <div class="method-description"> + <p> +Try to look up using a key directly, or if that fails as a string, or as a +symbol as last resort. If a symbol conversion doesn&#8216;t exists, rescue +with a nil. +</p> + </div> + </div> + + <div id="method-M000005" class="method-detail"> + <a name="M000005"></a> + + <div class="method-heading"> + <a href="MethodicHash.src/M000005.html" target="Code" class="method-signature" + onclick="popupCode('MethodicHash.src/M000005.html');return false;"> + <span class="method-name">method_missing</span><span class="method-args">(method,*args)</span> + </a> + </div> + + <div class="method-description"> + <p> +A missing method is assummed to be the assignment of a value of a key, or +the lookup of a value with a key. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> </html> \ No newline at end of file