<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Ruby String#Nameize Revised</title>
	<atom:link href="http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/</link>
	<description>Building a Better Internet</description>
	<lastBuildDate>Wed, 10 Mar 2010 03:36:31 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Patrick Tulskie</title>
		<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/comment-page-1/#comment-96</link>
		<dc:creator>Patrick Tulskie</dc:creator>
		<pubDate>Sun, 20 Sep 2009 23:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricktulskie.com/?p=102#comment-96</guid>
		<description>Thanks for that raggi.  Great set of tweaks.  Yeah I&#039;ve come to learn a great deal since I originally wrote this dirty code.  Case has been one of those things I&#039;ve stopped abusing such as you saw before.  I&#039;m glad that people are still finding this useful and improving upon it.  As you&#039;ll probably notice, I&#039;ve stopped writing on my blog as much and have been reading through the code of others&#039; as of late.</description>
		<content:encoded><![CDATA[<p>Thanks for that raggi.  Great set of tweaks.  Yeah I&#8217;ve come to learn a great deal since I originally wrote this dirty code.  Case has been one of those things I&#8217;ve stopped abusing such as you saw before.  I&#8217;m glad that people are still finding this useful and improving upon it.  As you&#8217;ll probably notice, I&#8217;ve stopped writing on my blog as much and have been reading through the code of others&#8217; as of late.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raggi</title>
		<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/comment-page-1/#comment-95</link>
		<dc:creator>raggi</dc:creator>
		<pubDate>Thu, 10 Sep 2009 16:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricktulskie.com/?p=102#comment-95</guid>
		<description>I can see where you&#039;re trying to apply &quot;performance optimizations&quot; but they&#039;re introducing bugs, that you don&#039;t seem to have benchmark, profile, or test coverage for.

You don&#039;t need gsub with a regex of /^ ... /

You could do the entire sub line operation in a single sub, and probably should do. Sub isn&#039;t delete, afterall. Oh, and the two sub cases are equivalent, with a different first group.

Stop using String#match without utilising the match data, and for that matter, use case properly, rather than this new way you&#039;ve learned.

Oh screw it... here comes codes...

&lt;em&gt;
&lt;code&gt;
class String
  SPACE = &#039; &#039;
  APOS = &quot;&#039;&quot;

  # Extension of the string class to properly handle camel names
  def nameize
    case self
    when / /
      # If the name has a space in it, we gotta run the parts through the nameizer.
      split(SPACE).each { &#124;part&#124; part.nameize! }.join(SPACE)
    when /^[A-Z]/
      # If they took the time to capitalize their name then let&#039;s just jump out.
      self
    when /^(mac&#124;mc)(\w)(.*)$/i
      &quot;#{$1.capitalize}#{$2.capitalize}#{$3}&quot;
    when /^o\&#039;/i
      split(APOS).each{ &#124;piece&#124; piece.capitalize! }.join(APOS)
    else
      capitalize # Basically if the name is a first name or it&#039;s not Irish then capitalize it.
    end
  end

  def nameize!
    replace nameize # BANG!
  end

end

require &#039;rubygems&#039;
require &#039;minitest/unit&#039;
include MiniTest::Assertions
assert_equal(&quot;Martin O&#039;Donald&quot;, &quot;martin o&#039;donald&quot;.nameize)
assert_equal(&quot;Randy McFarley&quot;, &quot;Randy mcfarley&quot;.nameize)
assert_equal(&quot;Sue MacDonald&quot;, &quot;sue macdonald&quot;.nameize)
&lt;/code&gt;
&lt;/em&gt;

Have fun, and play safe.</description>
		<content:encoded><![CDATA[<p>I can see where you&#8217;re trying to apply &#8220;performance optimizations&#8221; but they&#8217;re introducing bugs, that you don&#8217;t seem to have benchmark, profile, or test coverage for.</p>
<p>You don&#8217;t need gsub with a regex of /^ &#8230; /</p>
<p>You could do the entire sub line operation in a single sub, and probably should do. Sub isn&#8217;t delete, afterall. Oh, and the two sub cases are equivalent, with a different first group.</p>
<p>Stop using String#match without utilising the match data, and for that matter, use case properly, rather than this new way you&#8217;ve learned.</p>
<p>Oh screw it&#8230; here comes codes&#8230;</p>
<p><em><br />
<code><br />
class String<br />
  SPACE = ' '<br />
  APOS = "'"</p>
<p>  # Extension of the string class to properly handle camel names<br />
  def nameize<br />
    case self<br />
    when / /<br />
      # If the name has a space in it, we gotta run the parts through the nameizer.<br />
      split(SPACE).each { |part| part.nameize! }.join(SPACE)<br />
    when /^[A-Z]/<br />
      # If they took the time to capitalize their name then let's just jump out.<br />
      self<br />
    when /^(mac|mc)(\w)(.*)$/i<br />
      "#{$1.capitalize}#{$2.capitalize}#{$3}"<br />
    when /^o\'/i<br />
      split(APOS).each{ |piece| piece.capitalize! }.join(APOS)<br />
    else<br />
      capitalize # Basically if the name is a first name or it's not Irish then capitalize it.<br />
    end<br />
  end</p>
<p>  def nameize!<br />
    replace nameize # BANG!<br />
  end</p>
<p>end</p>
<p>require 'rubygems'<br />
require 'minitest/unit'<br />
include MiniTest::Assertions<br />
assert_equal("Martin O'Donald", "martin o'donald".nameize)<br />
assert_equal("Randy McFarley", "Randy mcfarley".nameize)<br />
assert_equal("Sue MacDonald", "sue macdonald".nameize)<br />
</code><br />
</em></p>
<p>Have fun, and play safe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brookr</title>
		<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/comment-page-1/#comment-94</link>
		<dc:creator>Brookr</dc:creator>
		<pubDate>Fri, 28 Aug 2009 06:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricktulskie.com/?p=102#comment-94</guid>
		<description>Thanks for sharing this, just what I needed!</description>
		<content:encoded><![CDATA[<p>Thanks for sharing this, just what I needed!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oz</title>
		<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/comment-page-1/#comment-60</link>
		<dc:creator>Oz</dc:creator>
		<pubDate>Sat, 07 Feb 2009 07:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricktulskie.com/?p=102#comment-60</guid>
		<description>Hey Patrick, sorry that this comment isn&#039;t really about the post, but I just saw this site and I really like it! Nice layout and everything. I enjoy your writing style too</description>
		<content:encoded><![CDATA[<p>Hey Patrick, sorry that this comment isn&#8217;t really about the post, but I just saw this site and I really like it! Nice layout and everything. I enjoy your writing style too</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clinton Skakun</title>
		<link>http://www.patricktulskie.com/2008/12/ruby-string-nameize-revised/comment-page-1/#comment-57</link>
		<dc:creator>Clinton Skakun</dc:creator>
		<pubDate>Wed, 21 Jan 2009 23:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.patricktulskie.com/?p=102#comment-57</guid>
		<description>Can&#039;t wait to get into Ruby! Looks awesome.

Currently, I use PHP for application development. Instead of using Ruby for that I&#039;m going to use it for building programs with GUIs. I&#039;m looking into building in GTK and Qt. GTK because it&#039;s entirely free and Qt because it&#039;s the best, even though the license costs money. Never know I might buy it, but not until I&#039;m made some real money on software development.

Anyways I think it&#039;s great that you&#039;re into Ruby.

Have a great one!
Clinton Skakun</description>
		<content:encoded><![CDATA[<p>Can&#8217;t wait to get into Ruby! Looks awesome.</p>
<p>Currently, I use PHP for application development. Instead of using Ruby for that I&#8217;m going to use it for building programs with GUIs. I&#8217;m looking into building in GTK and Qt. GTK because it&#8217;s entirely free and Qt because it&#8217;s the best, even though the license costs money. Never know I might buy it, but not until I&#8217;m made some real money on software development.</p>
<p>Anyways I think it&#8217;s great that you&#8217;re into Ruby.</p>
<p>Have a great one!<br />
Clinton Skakun</p>
]]></content:encoded>
	</item>
</channel>
</rss>

