From: Dave Thomas Date: 2002-12-22T00:12:11+09:00 Subject: Re: String#to_class? On Sat, 2002-12-21 at 03:00, Tim Bates wrote: > I have a class being used in a unit test: > > TC_Foo > > I match it against a regexp: > > /TC_(.*)/.match(self.class.name) > > I end up with a string ($1 == "Foo") which I want to be an instance of Class > (== Foo). How can I convert a String to a Class? Will I have to use > ObjectSpace to find a Class whose Class#name == "Foo"? There's a page on the Wiki with a number of solutions: http://www.rubygarden.org/ruby?FindClassesByName Cheers Dave