From: Ara.T.Howard@... Date: 2005-05-04T04:34:51+09:00 Subject: Re: un_metaclass On Wed, 4 May 2005, Ilmari Heikkinen wrote: > > On 3.5.2005, at 21:24, Ara.T.Howard@noaa.gov wrote: > >> On Tue, 3 May 2005, Robert Klemme wrote: >> >>> Ara.T.Howard wrote: >>>> thoughts on how to do this >>>> >>>> class C >>>> class << self >>>> p un_metaclass #=> C >>>> end >>>> end >>>> >>>> ?? >>> >>> I'd prefer to call it #instance 'cause that's what it is. :-) >> >> >> hmmm. ok. any ideas? i'm playing with nesting and ancestors - but >> no luck. >> > > There's this terrible hack: > > class Class > def un_metaclass > to_s.scan(/:[^A-Z]*(([A-Za-z0-9]*(::)?)+)/)[0][0]. > split("::").inject(Object){|m, n| m.const_get(n)} > end > end > > It's not something I'd like to use though :-) is that perl? ;-) -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | renunciation is not getting rid of the things of this world, but accepting | that they pass away. --aitken roshi ===============================================================================