Possible Duplicate:
How to turn a string into a method call?
Currently I have a code that is doing something like this
def execute
case @command
when "sing"
sing()
when "ping"
user_defined_ping()
when "--help|-h|help"
get_usage()
end
I find the case pretty useless and huge and I had like to call the appropriate method just by using the variable @command. Something like:
def execute
@command()
end
Offcourse I would not need and extra execute() method in this case.
Any suggestions on how I can acheive this ruby ?
Thanks!
Edit: Added other method type for multiple strings. Not sure if that can also be handled in an elegant manner.