doc/atomic-rdoc/classes/String.src/M000248.html in facets-0.7.1 vs doc/atomic-rdoc/classes/String.src/M000248.html in facets-0.7.2

- old
+ new

@@ -3,16 +3,36 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>rand_letter (String)</title> + <title>last (String)</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/facet/string/rand_letter.rb, line 10</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-constant">String</span>.<span class="ruby-identifier">rand_letter</span> - (<span class="ruby-identifier">rand</span>(<span class="ruby-value">26</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value">65</span> <span class="ruby-operator">:</span> <span class="ruby-value">97</span>) ).<span class="ruby-identifier">chr</span> + <pre><span class="ruby-comment cmt"># File lib/facet/string/last.rb, line 18</span> + <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last</span>(<span class="ruby-identifier">n</span>=<span class="ruby-value">1</span>, <span class="ruby-identifier">pattern</span>=<span class="ruby-value str">''</span>) + <span class="ruby-identifier">pattern</span> = <span class="ruby-value str">''</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pattern</span> <span class="ruby-operator">==</span> <span class="ruby-regexp re">//</span> + <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">pattern</span> + <span class="ruby-keyword kw">when</span> <span class="ruby-value str">''</span> + <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">slice</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">n</span>, <span class="ruby-identifier">n</span>) <span class="ruby-comment cmt"># RETURNS</span> + <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;\n&quot;</span> + <span class="ruby-identifier">pattern</span> = <span class="ruby-regexp re">/\n+|\Z/</span> + <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span> + <span class="ruby-identifier">pattern</span> = <span class="ruby-regexp re">/\s+|\Z/</span> + <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span> + <span class="ruby-identifier">pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>( <span class="ruby-identifier">separator</span> ) ) <span class="ruby-comment cmt">#if String === separator</span> + <span class="ruby-keyword kw">end</span> + + <span class="ruby-identifier">rself</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">reverse</span> + <span class="ruby-identifier">i</span>,<span class="ruby-identifier">s</span>,<span class="ruby-identifier">e</span> = <span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span> + <span class="ruby-identifier">n</span>.<span class="ruby-identifier">times</span> { + <span class="ruby-identifier">i</span> = <span class="ruby-identifier">rself</span>.<span class="ruby-identifier">index</span>( <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">s</span> ) + <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">i</span> + <span class="ruby-identifier">e</span> = <span class="ruby-identifier">i</span> + <span class="ruby-identifier">s</span> = <span class="ruby-identifier">$~</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>) + } + <span class="ruby-identifier">rself</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">e</span>).<span class="ruby-identifier">reverse</span> <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file