From: "Llelan D." Date: 2012-05-23T00:39:27+09:00 Subject: Re: Opinion on String#camelcase Thomas Sawyer wrote in post #1061685: > Of course, there is still the optional argument too: > > "foo_man".camelcase(:upper) #=> 'FooMan" > "Foo_man".camelcase(:lower) #=> 'fooMan" > > Does this approach make sense to others? I would expect a camelcase() method to leave the first character alone unless I specified an action, so your change is welcome. In addition, you should provide a default behavior method like camelcase_defaultfirstchar(arg) with arg being one of :none, :upper, or :lower with :none as default (or some kind of well-documented app-wide configuration). This allows the developer to make their own decision, to change their mind with one global configuration change, and to upgrade old code with one configuration change rather than an app-wide search for all uses and side-effects. Thomas Sawyer wrote in post #1061685: > To which end I also added #uppercase and > #lowercase methods to alter just the first character. So one can do: > > "foo_man".camelcase #=> 'fooMan" > "foo_man".uppercase.camelcase #=> 'FooMan" > "Foo_man".lowercase.camelcase #=> 'fooMan" The names of the first-char conversion methods should reflect that only the first character is converted like upcase_first and downcase_first (The names 'upcase' and 'downcase' would keep them consistent with the core String method names). You probably also want '!' versions of each to perform destructive conversions on the original String. I hope you find that helpful. -- Posted via http://www.ruby-forum.com/.