--6K2R/cS9K4qvcBNq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Dave Thomas (dave / pragprog.com) wrote:
> 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 instancef 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

I don't know if the original poster needs it, but The examples there
don't work with anonymous classes or non-colon delimited class names.
The bit I wrote does.

> Cheers
> 
> 
> Dave
> 
> 

-- 
Paul Duncan <pabs / pablotron.org>        pabs in #gah (OPN IRC)
http://www.pablotron.org/               OpenPGP Key ID: 0x82C29562

--6K2R/cS9K4qvcBNq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+C3jYzdlT34LClWIRAvhgAKDXjq8Bg/sAS3c7ieTPxfFHQkvSIwCgu1lf
3w0VmbfNHcmX1AtiaLfjIEI1
-----END PGP SIGNATURE-----

--6K2R/cS9K4qvcBNq--