From: Claus Spitzer Date: 2004-08-15T05:03:08+09:00 Subject: Re: creating classes on the fly Great! Thanks for the quick response. Just another quick one on that context: Now that I have the class definition and can extend it easily, I'm wondering how I would do qux = Klass.new using str1 or klass. I could do eval "qux = #{str}.new" and that would be fine, but it somehow seems forced. Any hints? On Sun, 15 Aug 2004 04:40:41 +0900, Sam Stephenson wrote: > On Sun, 15 Aug 2004 04:31:11 +0900, Claus Spitzer > wrote: > > I'm stuck on the ??? part. I tried > > > > class eval( str1 ) > > > > I tried > > > > class str.intern # (I think I know by now why this one was a stupid idea) > > > > I tried > > > > $myclassref = eval str1 > > class $myclassref > > > > All to no avail. So I'm wondering whether I'm trying to do this the > > wrong way. What would be the Ruby way of solving this problem? > > > > | klass = eval(str1) > | klass.class_eval do > | include Mod > | end > > Sam > >