From: "guillaume.dorchies" Date: 2004-03-19T00:04:32+09:00 Subject: Re: Find a class by its name when this name is in a string Le Thu, 18 Mar 2004 10:33:51 +0000, gabriele renzi a �crit�: > il Thu, 18 Mar 2004 11:22:00 +0100, "guillaume.dorchies" > ha scritto:: > >>Hello >> >>I need to find a classe when I have its name in a string like this > > your FIND is Module#const_get > > irb(main):001:0> Object::const_get 'Class' > => Class > irb(main):002:0> class Mia; end > => nil > irb(main):003:0> Object::const_get('Mia').new > => # Ok thank but with old messages I make this method module Introspection class ClassNotFound < Exception ; end class Find def self.find_class(class_name) ObjectSpace.each_object(Module) do |n| if n.name==class_name then return n end end raise ClassNotFound end end end