There’s been a great response to my request to convert Title Case, Gruber’s nifty perl-based title-casing tool into Ruby so the rest of the world (just kidding, Perl people!) can make use of it.
Here are the initial responders:
- http://frankschmitt.org/projects/title-case
- http://github.com/caius/titlecase.rb/tree/master/
- http://github.com/h3h/rb-title-case
- http://github.com/infovore/titlecase/tree/master
- http://github.com/jlindley/title_case
- http://github.com/justinfrench/string_extensions/tree/master
- http://github.com/samaaron/titlecase-rb/tree/master
- http://mucur.name/posts/ruby-title-case
- http://pastie.caboo.se/201181
- http://vengefulcow.com/titlecase/
- http://www.unfitforprint.com/articles/2008/05/21/gruber-style-title-case-in-ruby
If you, too, have a version, please post it to the comments.
I haven’t had a chance to check each of them out yet, but from first blush, it appears that we have some very elegant solutions here.
Commenting is not available in this weblog entry.






Jordan Sherer
21 May 2008 at 8:16 pm
The rest of the world is split 60-40 python vs ruby, or ruby vs python. (You can pick)
You can check out my interesting Python version of his script here:
http://widefido.com/static/wf/files/title_case.py.txt
Best,
Jordan
coyote
21 May 2008 at 9:06 pm
...don’t forget those of us who prefer Java & JSP.
Tim Case
21 May 2008 at 10:25 pm
I liked the Justin French version the best…
Michael Boutros
21 May 2008 at 10:41 pm
I tossed up a page just to explain how I went at it: http://www.michaelboutros.com/index.php/projects/titlecase
David Madden
21 May 2008 at 11:43 pm
http://moose56.com/blog/2008/05/22/titlecase/
Dave Phillips
22 May 2008 at 1:02 am
Short and sweet
http://pastie.caboo.se/201355
Dylan
22 May 2008 at 5:37 am
I remember reading a book in art school written by a respected designer from Xerox (I think it was Xerox, I might be incorrect). It was almost a style guide for their company, but presented in more of a “best practices” fashion for the wider design world. Anyway, one thing I learned from this was not to set titles in “camel case”. It’s only necessary to capitalise the first word.
Stephen
22 May 2008 at 6:31 am
It can depend on context, Dylan and is often a matter of style, like using a spaced en dash vs an em dash. Most newspapers and magazines stick to lower case, such as the Economist and Monocle. I tend to lean towards this approach, capitalising only the first word and proper nouns. A title is often itself a proper noun, however. If you were referring to an article in your body content, you would always use title case. It’s a point where typographers and designers can use their judgement, and earn their wage. ;)
John Zeratsky
22 May 2008 at 10:28 am
Stephen and Dylan:
I think it’s less important than the distinction between em and en dashes. With dashes, there are clear rules about which should be used where.
The decision to use “title case” or “sentence case” is truly one of preference, and I do not believe there are any agreed-upon rules for use. For example, the Associated Press uses sentence case, while the New York Times uses title case. Both organizations specify the capitalization scheme in their style manuals, but neither one is “right.”
aviet
22 May 2008 at 10:58 am
nobody prefers java…
Dan Benjamin
22 May 2008 at 12:52 pm
When it comes to things like title case, I tend to follow the rules as set forth by The Elements of Style by Strunk & White ($9.95 at Amazon). Their recommendation is to use title case for headings.
Martin DeMello
22 May 2008 at 2:05 pm
Some older code I wrote, based on Harbrace:
http://zem.novylen.net/ruby/titlecase.rb
Grant Hollingworth
22 May 2008 at 4:20 pm
http://rubyforge.org/projects/titleize
It’s available as a gem (gem install titleize) and is Rails-aware.