<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Curtis Summers</title>
	<atom:link href="http://csummers.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://csummers.com</link>
	<description>%w{life code ruby}.map { &#124;i&#124; "#{i} is awesome" }</description>
	<lastBuildDate>Fri, 30 Jan 2009 13:49:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>warning: default `to_a&#8217; will be obsolete</title>
		<link>http://csummers.com/2008/07/26/warning-default-to_a-will-be-obsolete/</link>
		<comments>http://csummers.com/2008/07/26/warning-default-to_a-will-be-obsolete/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 21:30:15 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://csummers.com/?p=9</guid>
		<description><![CDATA[Apparently Object.to_a will eventually be obsolete (not sure when).  I was using it in the following context:

def foo&#40;args&#41;
  args.to_a.join&#40;','&#41;
end

According to this very old ruby-lang thread, this [*args] is a suitable alternative:

def foo&#40;args&#41;
  &#91;*args&#93;.join&#40;','&#41;
end

]]></description>
			<content:encoded><![CDATA[<p>Apparently <a href="http://ruby-doc.org/core/classes/Object.html#M000628">Object.to_a</a> will eventually be obsolete (not sure when).  I was using it in the following context:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> foo<span style="color:#006600; font-weight:bold;">&#40;</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
  args.<span style="color:#9900CC;">to_a</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">','</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>According to <a href="http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/931de58e7189d355">this very old ruby-lang thread</a>, this [*args] is a suitable alternative:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> foo<span style="color:#006600; font-weight:bold;">&#40;</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">','</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2008/07/26/warning-default-to_a-will-be-obsolete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning git</title>
		<link>http://csummers.com/2008/07/26/learning-git/</link>
		<comments>http://csummers.com/2008/07/26/learning-git/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 11:54:50 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://csummers.com/?p=8</guid>
		<description><![CDATA[What?&#8230;you&#8217;re not using git yet? Everybody&#8217;s doing it.  It&#8217;s all the rage (at least for Rubyists)!
I finally blocked out everything else for a few hours yesterday afternoon to learn git.  A couple of observations coming from SVN:

The use of SHA1 hashes to identify revisions will take some time to get used to, but it appeals [...]]]></description>
			<content:encoded><![CDATA[<p>What?&#8230;you&#8217;re not using <a href="http://git.or.cz/">git</a> yet? <a href="http://git.or.cz/gitwiki/GitProjects">Everybody</a>&#8217;s doing it.  It&#8217;s <a href="http://www.rubyinside.com/git-and-ruby-git-tutorials-articles-and-links-for-rubyists-860.html">all the rage</a> (at least for Rubyists)!</p>
<p>I finally blocked out everything else for a few hours yesterday afternoon to learn git.  A couple of observations coming from SVN:</p>
<ul>
<li>The use of SHA1 hashes to identify revisions will take some time to get used to, but it appeals greatly to my inner geek.</li>
<li>No central repository (every clone is the full repository) makes me feel safer about my data somehow.</li>
<li>If you want a central repository like svn, use &#8220;git push &lt;repo-url&gt;&#8221;</li>
</ul>
<p>There are lots of resources and tutorials out there, but I found the <a href="http://git.or.cz/course/svn.html">SVN Crash Course</a> coupled with git&#8217;s own help pages &#8220;git &lt;command&gt; &#8211;help&#8221; to be all I needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2008/07/26/learning-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ramp up your testing for Safari/Webkit</title>
		<link>http://csummers.com/2007/11/07/ramp-up-your-testing-for-safariwebkit/</link>
		<comments>http://csummers.com/2007/11/07/ramp-up-your-testing-for-safariwebkit/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 12:55:16 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://csummers.com/?p=7</guid>
		<description><![CDATA[Do you test in Safari with the same priority as other browsers? If not, you might should start making it a part of your routine.  According to an article on Rob Pegoraro&#8217;s Faster Forward blog, Google&#8217;s new mobile OS, Android, contains a browser &#8220;built on the same open-source WebKit software as the Safari browser [...]]]></description>
			<content:encoded><![CDATA[<p>Do you test in Safari with the same priority as other browsers? If not, you might should start making it a part of your routine.  According to an <a href="http://blog.washingtonpost.com/fasterforward/2007/11/analyzing_googles_android_1.html">article on Rob Pegoraro&#8217;s Faster Forward blog</a>, Google&#8217;s new mobile OS, Android, contains a browser &#8220;built on the same open-source <a href="http://webkit.org/">WebKit</a> software as the Safari browser in Mac OS X and the iPhone.&#8221;</p>
<p>If Google can accomplish what they hope to with Android, namely, to be <em>the</em> mobile operating system, then developers will have yet another target browser to test for.  I&#8217;m not complaining, though, Safari/Webkit is a great browser.  And, as long as it maintains good adherence to web standards the additional testing only serves to better our web applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2007/11/07/ramp-up-your-testing-for-safariwebkit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ActiveYahoo: A Ruby API for Yahoo! Web Services</title>
		<link>http://csummers.com/2007/11/04/activeyahoo-a-ruby-api-for-yahoo-web-services/</link>
		<comments>http://csummers.com/2007/11/04/activeyahoo-a-ruby-api-for-yahoo-web-services/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 02:31:08 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[activeyahoo]]></category>

		<guid isPermaLink="false">http://csummers.com/?p=5</guid>
		<description><![CDATA[Do you Yahoo?  I do, and was recently a little disappointed in the Ruby offerings for the Yahoo Web Services API.  So, a little coding and we have ActiveYahoo:

require 'active_yahoo'
y = ActiveYahoo::WebSearch.new&#40;‘YOUR_APP_ID’, ‘ruby’, &#123; :results =&#62; 2 &#125;&#41;
y.result.total_results_returned  # =&#62; 2
y.result.records&#91;0&#93;.title  # =&#62; &#34;Ruby-lang.org&#34;
y.result.records.map &#123; &#124;r&#124; r.url &#125;
#  =&#62; [&#34;http://www.ruby-lang.org/en&#34;,
# [...]]]></description>
			<content:encoded><![CDATA[<p>Do you Yahoo?  I do, and was recently a little disappointed in the Ruby offerings for the Yahoo Web Services API.  So, a little coding and we have ActiveYahoo:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'active_yahoo'</span>
y = <span style="color:#6666ff; font-weight:bold;">ActiveYahoo::WebSearch</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>‘YOUR_APP_ID’, ‘ruby’, <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:results</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
y.<span style="color:#9900CC;">result</span>.<span style="color:#9900CC;">total_results_returned</span>  <span style="color:#008000; font-style:italic;"># =&gt; 2</span>
y.<span style="color:#9900CC;">result</span>.<span style="color:#9900CC;">records</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">title</span>  <span style="color:#008000; font-style:italic;"># =&gt; &quot;Ruby-lang.org&quot;</span>
y.<span style="color:#9900CC;">result</span>.<span style="color:#9900CC;">records</span>.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>r<span style="color:#006600; font-weight:bold;">|</span> r.<span style="color:#9900CC;">url</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#008000; font-style:italic;">#  =&gt; [&quot;http://www.ruby-lang.org/en&quot;,</span>
<span style="color:#008000; font-style:italic;">#      &quot;http://en.wikipedia.org/wiki/Ruby_programming_language&quot;]</span></pre></div></div>

<p>A primary objective of ActiveYahoo is to encapsulate Yahoo‘s responses into their own objects. For example, an instance of the WebSearch class will return a WebSearchResult object. Special care is also given to convert response fields into appropriate Ruby data types.</p>
<p>So far, the following Search services have been implemented:  Web, News, Images, Audio, and Video.  More will follow soon. The essentials are on Rubyforge here:</p>
<p><a href="http://rubyforge.org/projects/activeyahoo/">View the ActiveYahoo project page</a><br />
<a href="http://activeyahoo.rubyforge.org/">View the documentation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2007/11/04/activeyahoo-a-ruby-api-for-yahoo-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monotony vs. Usability Luster</title>
		<link>http://csummers.com/2007/11/03/monotony-vs-usability-luster/</link>
		<comments>http://csummers.com/2007/11/03/monotony-vs-usability-luster/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 16:39:57 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://csummers.com/?p=3</guid>
		<description><![CDATA[I think there is an interesting dynamic that occurs when a developer is freed up from the monotony of the development process.  Specifically, there is a direct consequence on the usability of a product when a developer&#8217;s progress in slowed by monotonous tasks.
As a developer, I&#8217;d love to claim that my initial design intentions [...]]]></description>
			<content:encoded><![CDATA[<p>I think there is an interesting dynamic that occurs when a developer is freed up from the monotony of the development process.  Specifically, there is a direct consequence on the usability of a product when a developer&#8217;s progress in slowed by monotonous tasks.</p>
<p>As a developer, I&#8217;d love to claim that my initial design intentions (sketches/wireframes, task flow) are spot-on every time.  Ha! Let&#8217;s be realistic: creating a good user experience is hard to do.</p>
<p>It is often the case that the product is near a finished state before some usability issues are encountered.  In other words, the product may be feature-complete, and deemed releasable, but it&#8217;s that extra effort towards usability that can really make a product shine.</p>
<p>What can we do as developers to make sure our end product has that finishing touch?  Or, more specifically, what blockers exist to keep us from achieving this goal?</p>
<p>I&#8217;d suggest monotony is a key blocker:</p>
<p><img src="http://csummers.com/wp-content/uploads/2007/11/monotony_vs_usability.png" alt="Monotony vs Usability Luster" /></p>
<p>Let&#8217;s define our two forces at play:</p>
<ul>
<li>Monotony &#8211; any repetitive, tedious process, task, or routine that drags down creativity during the development process</li>
<li>Usability Luster &#8211; the extra, finishing touches on a product that exponentially elevate the product&#8217;s usability</li>
</ul>
<p>For a developer, more monotony means less time and space (grey matter space) to cope with finishing touches.  If, as a developer, I feel like a cubicle code monkey all day, every day, then that is affecting my ability to push out a quality user experience.</p>
<p>How can we combat monotony?</p>
<ul>
<li>Use tools that reduce monotony and increase productivity
<ul>
<li>Rails comes to mind</li>
</ul>
<ul>
<li>A good IDE</li>
</ul>
</li>
<li>Use good programming technique
<ul>
<li>DRY (Don&#8217;t Repeat Yourself)</li>
</ul>
<ul>
<li>Design Patterns (where appropriate)</li>
</ul>
<ul>
<li>Test (reduce your stress level by testing)</li>
</ul>
</li>
<li>Get a cheerleader
<ul>
<li> Find that guy/gal who encourages you through the monotony</li>
</ul>
</li>
</ul>
<p>What do you do to get through the monotony?  What other techniques do you use to ensure that little something extra for the user experience?</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2007/11/03/monotony-vs-usability-luster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby: Recursive send</title>
		<link>http://csummers.com/2007/01/18/ruby-recursive-send/</link>
		<comments>http://csummers.com/2007/01/18/ruby-recursive-send/#comments</comments>
		<pubDate>Thu, 18 Jan 2007 20:02:25 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.csummers.org/index.php/2007/01/18/ruby-recursive-send/</guid>
		<description><![CDATA[Ruby&#8217;s Object#send allows dynamic calling of a method.  This is very useful, but what if we wanted to call several levels deep on an object?  For instance:

# Normal call chain
post.comments.first.commented_at
&#160;
# Dynamically with send?  Have to call three times.
post.send&#40;:comments&#41;.send&#40;:first&#41;.send&#40;:commented_at&#41;

What if the number of calls to send is variable depending on what we&#8217;re trying [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby&#8217;s Object#send allows dynamic calling of a method.  This is very useful, but what if we wanted to call several levels deep on an object?  For instance:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;"># Normal call chain</span>
post.<span style="color:#9900CC;">comments</span>.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">commented_at</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Dynamically with send?  Have to call three times.</span>
post.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:comments</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:first</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:commented_at</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>What if the number of calls to send is variable depending on what we&#8217;re trying to show?  In one case we might need <span style="font-family: mono">post.posted_at</span> for the date, and in another case we might need <span style="font-family: mono">post.comments.first.commented_at</span> for the date.</p>
<p>How could we dynamically craft the definition of the methods to send if we don&#8217;t know how many calls to Object#send we&#8217;ll have?  We need a way to define an arbitrary number of method calls.</p>
<p>Behold, a recursive send:  Object#rsend</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> rsend<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
    obj = <span style="color:#0000FF; font-weight:bold;">self</span>
    args.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>a<span style="color:#006600; font-weight:bold;">|</span>
      b = <span style="color:#006600; font-weight:bold;">&#40;</span>a.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">Array</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> a.<span style="color:#9900CC;">last</span>.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">Proc</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? a.<span style="color:#9900CC;">pop</span> : block<span style="color:#006600; font-weight:bold;">&#41;</span>
      obj = obj.__send__<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>a, <span style="color:#006600; font-weight:bold;">&amp;</span>b<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    obj
  <span style="color:#9966CC; font-weight:bold;">end</span>
  alias_method <span style="color:#ff3333; font-weight:bold;">:__rsend__</span>, <span style="color:#ff3333; font-weight:bold;">:rsend</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Each argument passed to Object#rsend is an array with the symbols and arguments that will be passed on to Object#send:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">post.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:comments</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:first</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:commented_at</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>If there are no arguments to be passed on to send, the array brackets can be omitted:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">post.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:comments</span>, <span style="color:#ff3333; font-weight:bold;">:first</span>, <span style="color:#ff3333; font-weight:bold;">:commented_at</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Of course, in practice you&#8217;ll probably be defining your method call chain in one part of your code, putting it in a variable, and sending it to rsend with a splat*:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">the_date = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:comments</span>, <span style="color:#ff3333; font-weight:bold;">:first</span>, <span style="color:#ff3333; font-weight:bold;">:commented_at</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#...somewhere else in your code you've passed the_date along:</span>
post.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>the_date<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>With arguments:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>,<span style="color:#006666;">1</span>,<span style="color:#006666;">2</span>,<span style="color:#006666;">3</span>,<span style="color:#006666;">4</span>,<span style="color:#006666;">5</span>,<span style="color:#006666;">6</span>,<span style="color:#006666;">7</span>,<span style="color:#006666;">8</span>,<span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:slice</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#=&gt; [2, 3, 4, 5, 6, 7, 8, 9]</span>
&nbsp;
a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:slice</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:slice</span>, <span style="color:#006666;">1</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#=&gt; [3, 4, 5]</span></pre></div></div>

<p>Object#send accepts a block.  What about blocks?  Pass in a proc:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:map</span>, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#008000; font-style:italic;">#=&gt; [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]</span>
&nbsp;
a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:map</span>, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
        <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:select</span>, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">4</span> == <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#008000; font-style:italic;">#=&gt; [0, 4, 8, 12, 16]</span></pre></div></div>

<p>And, in an effort to make Object#rsend behave like Object#send for the simple case, you can send a regular block:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:map</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#008000; font-style:italic;">#=&gt; [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]</span></pre></div></div>

<p>Caveat:  For the case needing parameters, Object#rsend does require an array, so:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:slice</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># wrong, does not work like Object#send</span>
&nbsp;
a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:slice</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># right</span></pre></div></div>

<p>A quirk that I&#8217;ve left in for fun, but it might (and maybe should) change:  If providing a single block, that block will be called on every call unless you&#8217;ve already passed in a proc:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:map</span>, <span style="color:#ff3333; font-weight:bold;">:map</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#008000; font-style:italic;">#=&gt; [0, 4, 8, 12, 16, 20, 24, 28, 32, 36]</span>
&nbsp;
a.<span style="color:#9900CC;">rsend</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:map</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:map</span>, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006666;">+5</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:map</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#008000; font-style:italic;">#=&gt; [10, 14, 18, 22, 26, 30, 34, 38, 42, 46]</span>
  <span style="color:#008000; font-style:italic;">#outer block was called on first and third :map</span></pre></div></div>

<p>Can anyone come up with a good use for this call-the-block-each-time behavior?</p>
<p>Has anyone done this already?  I searched for such a thing and came up empty.  Maybe this method should be called something else?  I named it based on each call recursing down the chain of methods with a new object being returned for the next method to be sent to.</p>
<p>Suggestions and comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2007/01/18/ruby-recursive-send/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Do you have an idea folder?</title>
		<link>http://csummers.com/2006/11/29/do-you-have-an-idea-folder/</link>
		<comments>http://csummers.com/2006/11/29/do-you-have-an-idea-folder/#comments</comments>
		<pubDate>Wed, 29 Nov 2006 12:16:46 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.csummers.org/index.php/2006/11/29/do-you-have-an-idea-folder/</guid>
		<description><![CDATA[I have an idea folder.  It&#8217;s just a folder with a bunch of text files in it.  Each text file contains an idea.  Some ideas are potential business ideas, others are programming projects that I think would be useful, others are book/article ideas.  If it&#8217;s an idea, it goes in the [...]]]></description>
			<content:encoded><![CDATA[<p>I have an idea folder.  It&#8217;s just a folder with a bunch of text files in it.  Each text file contains an idea.  Some ideas are potential business ideas, others are programming projects that I think would be useful, others are book/article ideas.  If it&#8217;s an idea, it goes in the idea folder.</p>
<p>I&#8217;ve only been doing this for about six months, and in that time I&#8217;ve managed to come up with ideas to keep me busy working for several years!</p>
<p>Do you have an idea folder?</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2006/11/29/do-you-have-an-idea-folder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OpenDNS</title>
		<link>http://csummers.com/2006/11/06/opendns/</link>
		<comments>http://csummers.com/2006/11/06/opendns/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 21:54:01 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[tech tips]]></category>

		<guid isPermaLink="false">http://www.csummers.org/index.php/2006/11/06/opendns/</guid>
		<description><![CDATA[Every so often our cable internet (Time Warner Road Runner) will go &#8220;out.&#8221;  Only it&#8217;s not really &#8220;out&#8221;:  the cable modem&#8217;s internet connection is still on and I can ping IP addresses.  What&#8217;s really happening is Road Runner&#8217;s DNS servers stop responding to DNS queries.  This doesn&#8217;t happen very often, and [...]]]></description>
			<content:encoded><![CDATA[<p>Every so often our cable internet (Time Warner Road Runner) will go &#8220;out.&#8221;  Only it&#8217;s not really &#8220;out&#8221;:  the cable modem&#8217;s internet connection is still on and I can ping IP addresses.  What&#8217;s really happening is Road Runner&#8217;s DNS servers stop responding to DNS queries.  This doesn&#8217;t happen very often, and it is usually resolved in a few minutes, but that&#8217;s too long when I&#8217;m trying to work.</p>
<p>The solution:  <a href="http://www.opendns.com">OpenDNS</a>.  These guys run a top-notch DNS service.  It&#8217;s free, <a href="http://www.opendns.com/stats/">reliable</a>, fast, and supposedly <a href="http://www.opendns.com/what/">safer</a>.  The <a href="http://www.opendns.com/start/">Getting Started</a> page has detailed instructions for using OpenDNS&#8217;s servers in place of your ISP&#8217;s servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2006/11/06/opendns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CakePHP in a subdirectory; no trailing slash</title>
		<link>http://csummers.com/2006/11/02/cakephp-in-a-subdirectory-no-trailing-slash/</link>
		<comments>http://csummers.com/2006/11/02/cakephp-in-a-subdirectory-no-trailing-slash/#comments</comments>
		<pubDate>Thu, 02 Nov 2006 21:54:05 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.csummers.org/index.php/2006/11/02/cakephp-in-a-subdirectory-no-trailing-slash/</guid>
		<description><![CDATA[I recently worked on a project using the CakePHP web framework.  One problem I had was placing the framework in a subdirectory of the main website and accessing the application without a trailing slash:
This worked:
http://mysite.com/sub/
This did not:
http://mysite.com/sub
Usually Apache figures out that &#8220;sub&#8221; is a directory and will redirect to the slashed location for you. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently worked on a project using the <a href="http://www.cakephp.org/">CakePHP</a> web framework.  One problem I had was placing the framework in a subdirectory of the main website and accessing the application without a trailing slash:</p>
<p>This worked:</p>
<p>http://mysite.com/sub/</p>
<p>This did not:</p>
<p>http://mysite.com/sub</p>
<p>Usually Apache figures out that &#8220;sub&#8221; is a directory and will redirect to the slashed location for you.  However, CakePHP&#8217;s default mod_rewrite rules play havoc with this and the result was a 400 Bad Request error.  The solution is relatively simple, but was not intuitively easy to figure out.</p>
<p>CakePHP ships with this .htaccess file in the base CakePHP directory:</p>
<pre>
&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine  on
  RewriteRule ^$  app/webroot/     [L]
  RewriteRule (.*) app/webroot/$1  [L]
&lt;/IfModule&gt;
</pre>
<p>In my attempts to solve this problem, I had tried several rewrite rules and redirects from within this file and from within my website&#8217;s root web directory (one above the CakePHP directory), but only the following worked for me:</p>
<p>1.) Put this in your website root directory (where &#8220;sub&#8221; is your CakePHP directory):</p>
<pre>
&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine  on
  RewriteRule ^sub$       sub/app/webroot/     [L]
  RewriteRule ^sub/(.*)$ sub/app/webroot/$1  [L]
&lt;/IfModule&gt;
</pre>
<p>2) <b>AND, DELETE OR RENAME your .htaccess file in the CakePHP sub directory</b>.</p>
<p>Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2006/11/02/cakephp-in-a-subdirectory-no-trailing-slash/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Extend String to use ActionView&#8217;s Text Helpers</title>
		<link>http://csummers.com/2006/08/07/extend-string-to-use-actionviews-text-helpers/</link>
		<comments>http://csummers.com/2006/08/07/extend-string-to-use-actionviews-text-helpers/#comments</comments>
		<pubDate>Mon, 07 Aug 2006 21:54:02 +0000</pubDate>
		<dc:creator>Curt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://www.csummers.org/index.php/2006/08/07/extend-string-to-use-actionviews-text-helpers/</guid>
		<description><![CDATA[Ruby on Rails and Ruby are an amazing combo.  Here&#8217;s another example of why.
ActionView&#8217;s TextHelper methods are useful, but I often need to use them in my controller or my model.  For several of the TextHelper methods that expect a string as input, it makes sense to extend the String class.
So, if I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rubyonrails.com/">Ruby on Rails</a> and <a href="http://www.ruby-lang.org/en/">Ruby</a> are an amazing combo.  Here&#8217;s another example of why.</p>
<p>ActionView&#8217;s TextHelper methods are useful, but I often need to use them in my controller or my model.  For several of the TextHelper methods that expect a string as input, it makes sense to extend the String class.</p>
<p>So, if I want to strip HTML tags, auto link any URLs, and then simple format a comment (in that order) before I save it in the database I can do:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Comment <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
<span style="color:#008000; font-style:italic;">#...</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> before_save
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">text</span> = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">text</span>.<span style="color:#9900CC;">strip_tags</span>.<span style="color:#9900CC;">auto_link</span>.<span style="color:#9900CC;">simple_format</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This method is much cleaner than including ActionView::Helpers::TextHelper in whatever class I&#8217;m in and passing the string as an argument to each method.</p>
<p>Below is the magic code.  Since TextHelper is a module, we create a Singleton class to reference the methods, create the wrapper methods in their own module, and finally include that module in the String class.  Note that not all TextHelper methods are included&#8211;just the ones that make sense.  Drop this code into a file and require it in your environment or within a plugin.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;"># ActionView Text Helpers are great!</span>
<span style="color:#008000; font-style:italic;"># Let's extend the String class to allow us to call</span>
<span style="color:#008000; font-style:italic;"># some of these methods directly on a String.</span>
<span style="color:#008000; font-style:italic;"># Note:</span>
<span style="color:#008000; font-style:italic;">#  - cycle-related methods are not included</span>
<span style="color:#008000; font-style:italic;">#  - concat is not included</span>
<span style="color:#008000; font-style:italic;">#  - pluralize is not included because it is in</span>
<span style="color:#008000; font-style:italic;">#       ActiveSupport String extensions already</span>
<span style="color:#008000; font-style:italic;">#       (though they differ).</span>
<span style="color:#008000; font-style:italic;">#  - markdown requires BlueCloth</span>
<span style="color:#008000; font-style:italic;">#  - textilize methods require RedCloth</span>
<span style="color:#008000; font-style:italic;"># Example:</span>
<span style="color:#008000; font-style:italic;"># &quot;&lt;b&gt;coolness&lt;/b&gt;&quot;.strip_tags -&gt; &quot;coolness&quot;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'singleton'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Singleton to be called in wrapper module</span>
<span style="color:#9966CC; font-weight:bold;">class</span> TextHelperSingleton
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#CC00FF; font-weight:bold;">Singleton</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">ActionView::Helpers::TextHelper</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">ActionView::Helpers::TagHelper</span> <span style="color:#008000; font-style:italic;">#tag_options needed by auto_link</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Wrapper module</span>
<span style="color:#9966CC; font-weight:bold;">module</span> MyExtensions <span style="color:#008000; font-style:italic;">#:nodoc:</span>
  <span style="color:#9966CC; font-weight:bold;">module</span> CoreExtensions <span style="color:#008000; font-style:italic;">#:nodoc:</span>
    <span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#CC0066; font-weight:bold;">String</span> <span style="color:#008000; font-style:italic;">#:nodoc:</span>
      <span style="color:#9966CC; font-weight:bold;">module</span> TextHelper
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> auto_link<span style="color:#006600; font-weight:bold;">&#40;</span>link = <span style="color:#ff3333; font-weight:bold;">:all</span>, href_options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">auto_link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, link, href_options, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> excerpt<span style="color:#006600; font-weight:bold;">&#40;</span>phrase, radius = <span style="color:#006666;">100</span>, excerpt_string = <span style="color:#996600;">&quot;...&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">excerpt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, phrase, radius, excerpt_string<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> highlight<span style="color:#006600; font-weight:bold;">&#40;</span>phrase, highlighter = <span style="color:#996600;">'&lt;strong class=&quot;highlight&quot;&gt;<span style="color:#000099;">\1</span>&lt;/strong&gt;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">highlight</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, phrase, highlighter<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">begin</span>
          require_library_or_gem <span style="color:#996600;">'bluecloth'</span>
&nbsp;
          <span style="color:#9966CC; font-weight:bold;">def</span> markdown
            TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">markdown</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span>
          <span style="color:#008000; font-style:italic;"># do nothing.  method will be undefined</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> sanitize
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">sanitize</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> simple_format
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">simple_format</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> strip_tags
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">strip_tags</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">begin</span>
          require_library_or_gem <span style="color:#996600;">'redcloth'</span>
&nbsp;
          <span style="color:#9966CC; font-weight:bold;">def</span> textilize
            TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">textilize</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
          <span style="color:#9966CC; font-weight:bold;">def</span> textilize_without_paragraph
            TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">textilize_without_paragraph</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span>
          <span style="color:#008000; font-style:italic;"># do nothing.  methods will be undefined</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> truncate<span style="color:#006600; font-weight:bold;">&#40;</span>length = <span style="color:#006666;">30</span>, truncate_string = <span style="color:#996600;">&quot;...&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">truncate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, length, truncate_string<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">def</span> word_wrap<span style="color:#006600; font-weight:bold;">&#40;</span>line_width = <span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          TextHelperSingleton.<span style="color:#9900CC;">instance</span>.<span style="color:#9900CC;">word_wrap</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, line_width<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># extend String with the TextHelper functions</span>
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">String</span> <span style="color:#008000; font-style:italic;">#:nodoc:</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">MyExtensions::CoreExtensions::<span style="color:#CC0066; font-weight:bold;">String</span>::TextHelper</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This idea and code was somewhat inspired by <a href="http://gabriel.gironda.org/articles/2006/02/08/using-helpers-inside-a-controller">Gabriel&#8217;s post on using helpers inside a controller</a>.  Thanks Gabriel!</p>
]]></content:encoded>
			<wfw:commentRss>http://csummers.com/2006/08/07/extend-string-to-use-actionviews-text-helpers/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
