From: Brian Candler Date: 2007-03-31T17:48:47+09:00 Subject: Re: Find the fully qualified name of a class from a string On Sat, Mar 31, 2007 at 05:54:42AM +0900, Nasir Khan wrote: > Say you have a class definition in a string - > > str = < module A > class B > def b > puts "hello" > end > end > end > EOF > > What is the easiest way to find out the fully qualified name of the class > there, namely "A::B" Interesting. I thought that in general you couldn't: m = Module.new Foo = m Bar = m module m # what's the *name* of the module we are in now?? end But actually Ruby rejects that, so you must say 'module Foo' or 'module Bar'