A Title Case Gem for Ruby
Titleizer is a gem that adds String#titleize (aliased as String#titlecase) to perform smart capitalisation of titles.
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Titleizer is a gem that adds String#titleize (aliased as String#titlecase) to perform smart capitalisation of titles.
Comments
This is very similar to active_support/inflector. I assume that the advantage in using this over that is the ‘smart capitalisation’ to which you alluded? This gem does not capitalize noun markers, prepositions, and such. In other words:
Using ActiveSupport::Inflector“terms of reference”.titleize #=> “Terms Of Reference”
Using the Titleizer gem“terms of reference”.titleize #=> “Terms of Reference”
I thought it important to clarify the difference.
Ahh, yes. Emphasis on “Smart”.
I did something similar to this when the challenge to port John Gruber’s TitleCase script from Perl to Ruby first came out. I enjoy the differences Ruby allows in syntax when driving towards a common output.
http://github.com/samsouder/titlecase/tree/master
Post a comment