From: Gavin Sinclair Date: 2004-02-01T23:21:52+09:00 Subject: Re: check whether a class is defined, listing all classes On Monday, February 2, 2004, 12:52:30 AM, David wrote: > Robert Klemme wrote: >>>But what if the class name to be checked is a string? >>>("Test::Unit::TestCase")? >> >> irb(main):005:0> eval "defined? " + "Test::Unit::TestCase" >> => nil >> irb(main):006:0> require 'test/unit/testcase' >> => true >> irb(main):007:0> eval "defined? " + "Test::Unit::TestCase" >> => "constant" > Hm, I should've added that I didn't want to involve 'eval'. But then why > not, I'll just need to check the input using a simple regexp. After all, > almost everything in Ruby (require, load, irb, class_eval) is using eval > anyway... Take a look at StandardClassExtensions on the Wiki. There's something in there just for you :) Cheers, Gavin