Gavin Kistner [mailto:gavin / refinery.com] wrote:

#> btw, is there a proper_case in ruby? like "test".proper_case 
#=> "Test"
#
# > cat case_test.rb
#class String
#     def titlecase!
#         self.downcase!
#         self.gsub!( /\b\w/ ){ |t| t.upcase }
#         self
#     end
#     def titlecase
#         self.dup.titlecase!
#     end
#end
#str = "hElLo WoRlD"
#case_methods = %w| downcase upcase capitalize titlecase |
#case_methods.each{ |method_name|
#     puts "%s.%-10s #=> %s" % [ str.inspect, method_name, str.send 
#(method_name) ]
#}
#
# > ruby case_test.rb
#"hElLo WoRlD".downcase   #=> hello world
#"hElLo WoRlD".upcase     #=> HELLO WORLD
#"hElLo WoRlD".capitalize #=> Hello world
#"hElLo WoRlD".titlecase  #=> Hello World
#

Ah, capitalize. Thanks, Gavin.

But I would prefer your suggested name of titlecase or capitalcase instead.
It's a lot easier when you search using "ri case".

Of course, that is just my case, and i accidentally got lost..

kind regards -botp

#