"David McCabe" <davemccabe / gmail.com> schrieb im Newsbeitrag 
news:1108179699.496561.195290 / l41g2000cwc.googlegroups.com...
> Robert's solution seems to do exactly what I want. Hurrah!
>
> The only thing I'm changing is making a hash with the new classes so
> that I can instantiate them easily given their names:
>
> Object.const_set klass_name, klass
> kinds[klass_name.intern] = klass
>
> called_for = :LongRange
> p kinds[called_for].new
>
> If this isn't the Right Thing in ruby, any pointers on better ways to
> do it would be appreciated.

IMHO you don't need the hash.  That's duplicating efforts the interpreter 
does for you already.  You can just use the class name:

# called_for can be a Symbol or String
Object.const_get(called_for).new

Kind regards

    robert