Hi,
I’d like to announce the first release of the ‘CrossCase’ module: a
mixin which auto-generates under_barred aliases for class or instance
methods with names which follow the camelCased naming conventions, and
vice-versa. E.g., in a class which mixes in CrossCase, defining the
#foo_bar method will also create an alias for that method called
#fooBar.
For example:
require 'crosscase’
class MyClass
include CrossCase
def underbarred_method; ...; end
def camelCasedMethod; ...; end
end
obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method
-or-
class MyClass
def underbarred_method; …; end
def camelCasedMethod; …; end
end
require 'crosscase’
MyClass.extend( CrossCase )
obj = MyClass::new
obj.underbarredMethod
obj.camel_cased_method
I wrote this module because I prefer camelCased method names, but also
wish to respect the preferences of my fellow Rubyists for whom such
practices are an abomination. And I’m too lazy to type
alias :twinkle_twinkle :twinkleTwinkle
for every method. It’s all about laziness. Or perhaps I’m catering to
my hubris. Or both; I’ll shut up now.
The project page is at:
http://www.deveiate.org/code/CrossCase.shtml
and may be downloaded from:
http://www.deveiate.org/code/CrossCase-0.01.tar.gz
This module requires Ruby >= 1.8.0; it has not been tested with 1.6.8 +
Ruby-shim, but that may also work as well. Suggestions, bug reports,
and comments welcomed.
···
–
Michael Granger ged@FaerieMUD.org
Rubymage, Believer, Architect
The FaerieMUD Consortium http://www.FaerieMUD.org/