[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: string -> symbol

Jeremy Hinegardner

5/22/2007 7:18:00 PM

On Wed, May 23, 2007 at 04:13:49AM +0900, mike.cahill@comcast.net wrote:
> ok - i'm officially an idiot.
>
> i want to dynamically alias the names of all methods in a module... i need to string-manipulate the original method name to get the new one. alias_method only takes symbol names and the only tricks i know to convert strings to symbols (i.e., method("this_func") and SomeClass.method_eval("this_func) don't apply.
>
> my_module.instance_modules.each{ |m|
> m_new_name = <string stuff on m>
> alias_method <what goes here?> <and what goes here?>
>
>
> more generally, is there some easy way to convert strings to symbols that i've missed?

"a_string".to_sym # => :a_string

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org