From: Bob Hutchison Date: 2005-10-18T21:42:37+09:00 Subject: Re: Class method aliasing Thanks! I think a variation of Ara's and Sean's suggestion with your's Robert cover the various circumstances I've got to deal with. Cheers, Bob On Oct 18, 2005, at 3:41 AM, Robert Klemme wrote: > Bob Hutchison wrote: > >> Hi, >> >> I'd like to confirm that I cannot use any kind of aliasing to tidy up >> the following situation: >> >> class Junk >> def Junk.info >> "blah blah blah" >> end >> >> def info >> Junk.info >> end >> end >> >> I'd really like to be able to write the following: >> >> puts Junk.info >> >> # then somewhere far from there... >> junk = Junk.new >> puts junk.info >> >> I don't find junk.class.info satisfying, and if that were a module >> method, then you have to know too much. >> >> I guess what I'm trying to do is make class/module methods directly >> available to instances, and it seems I can't do that (whatever the >> reason). >> >> Any better ideas are more than welcome. >> > > Here's another approach: > > module Helper > def info() 42 end > end > class Foo > include Helper > extend Helper > end > > >>> Foo.info >>> > => 42 > >>> Foo.new.info >>> > => 42 > > Kind regards > > robert > > > ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur --