From: James Byrne Date: 2008-12-11T05:01:06+09:00 Subject: Re: Given a string find the matching class botp wrote: > 3 you can then check the value returned by checking if it #is_a? Class ... > >> Object.const_get("XX").is_a? Class > => true >> Object.const_get("Xx").is_a? Class > => true >> Object.const_get("YY") > NameError: uninitialized constant YY > > now, if you want to find classes tucked in on other modules/classes, > you'll have to scan the whole ObjectSpace; eg, looking for a class > named "C" wc is in "A::B::C"... ... > ObjectSpace.each_object(Class).each {|x| p x if x.name =~ /^M/ } > Method > MatchData > Module > M::MM Many thanks for this lucid explanation. -- Posted via http://www.ruby-forum.com/.