[patch] for ri case sensitivity (was - RE: disable ri case se nsit ive)

#> btw, is there a proper_case in ruby? like "test".proper_case
#=> "Test"

···

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

#
# > 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

#

If you need a more rigorous implementation of titlecase, see
http://zem.novylen.net/ruby/titlecase.rb

martin

···

"Peña, Botp" <botp@delmonte-phil.com> wrote:

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".

FWIW, #titlecase is a distinctly different concept from #capitalize.
#capitalize downcases the entire string and then upcases the first character only.
#titlecase (as I wrote it) downcases everything, and then upcases the first letter of every word.

···

"Peña, Botp" <botp@delmonte-phil.com> wrote:

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".