To give you a better idea of what I was looking for, I'm trying to do
the Ruby equivalent of this Smalltalk code

  |myClassname myCat myClass|
  myCat := 'Foo Classes'.
  myClassname := 'MyClass'.
  (Smalltalk hasClassNamed: myClassname) ifTrue: [Smalltalk
removeClassNamed: myClassname].
  (Smalltalk organization) addCategory:myCat before: 'Kernel-Methods'.
  (ClassBuilder new) superclass:Object subclass: (myClassname
asSymbol) instanceVariableNames:''
                    classVariableNames: '' poolDictionaries: '' category: myCat.

  myClass := Smalltalk classNamed: myClassname.

  myClass addInstVarName: 'x';addClassVarName: 'X'.

  (myClass respondsTo: ('getx' asSymbol)) ifFalse:[
              myClass compile: 'getx
                  ^ x' classified: 'accessors'].
  (myClass canUnderstand: ('getX' asSymbol)) ifFalse:[
              myClass compile: 'getX
                  ^ X' classified: 'accessors'].
               
  Transcript clear;show: (myClass definition).
  Transcript cr;show: (myClass selectors).
  (myClass new) perform: ('getx' asSymbol); perform: ('getX' asSymbol). 

Cheers!
  -CWS

On Sat, 14 Aug 2004 15:30:57 -0400, Claus Spitzer
<docboobenstein / gmail.com> wrote:
> Greetings again! I'm trying to create a user-defined class on the fly.
> The idea would be for the user to provide a class name, maybe a
> superclass name, and some method definition as a string, e.g.
> 
>   str1 = "MyClass"
>   str2 = "Class"
>   str3 = "def bar \n p \"bar!\" \n end"
> 
> and then my program would perhaps do something like
> 
>   eval "class #{str1} < #{str2}\n #{str3} \n end"
> 
> So far so good. Security is not a concern, this is just for a proof of
> concept. But I would like to be able to then extend MyClass
> separately, e.g.
> 
>   module Mod
>     def bar
>        p "foo!"
>     end
>   end
> 
>   class ???
>      include Mod
>   end
> 
> 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?
>