doc/atomic-rdoc/classes/String.src/M000235.html in facets-0.7.1 vs doc/atomic-rdoc/classes/String.src/M000235.html in facets-0.7.2
- old
+ new
@@ -3,19 +3,25 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title>center_lines (String)</title>
+ <title>word_filter! (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/center_lines.rb, line 20</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">center_lines</span>(<span class="ruby-identifier">n</span>)
- <span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span>
- <span class="ruby-identifier">lines</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/\n/</span>)
- <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">center</span>(<span class="ruby-identifier">n</span>) <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> }
- <span class="ruby-identifier">s</span>
+ <pre><span class="ruby-comment cmt"># File lib/facet/string/word_filter.rb, line 8</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">word_filter!</span> <span class="ruby-comment cmt">#:yield:</span>
+ <span class="ruby-identifier">rest_of_string</span> = <span class="ruby-keyword kw">self</span>
+ <span class="ruby-identifier">wordfind</span> = <span class="ruby-regexp re">/(\w+)/</span>
+ <span class="ruby-identifier">offset</span> = <span class="ruby-value">0</span>
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">wmatch</span> = <span class="ruby-identifier">wordfind</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">rest_of_string</span>)
+ <span class="ruby-identifier">word</span> = <span class="ruby-identifier">wmatch</span>[<span class="ruby-value">0</span>]
+ <span class="ruby-identifier">range</span> = <span class="ruby-identifier">offset</span><span class="ruby-operator">+</span><span class="ruby-identifier">wmatch</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">...</span> <span class="ruby-identifier">offset</span><span class="ruby-operator">+</span><span class="ruby-identifier">wmatch</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
+ <span class="ruby-identifier">rest_of_string</span> = <span class="ruby-identifier">wmatch</span>.<span class="ruby-identifier">post_match</span>
+ <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">range</span>] = <span class="ruby-keyword kw">yield</span>( <span class="ruby-identifier">word</span> )
+ <span class="ruby-identifier">offset</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">rest_of_string</span>.<span class="ruby-identifier">length</span>
+ <span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
\ No newline at end of file