------art_49453_8457685.1175288081423
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Say you have a class definition in a string -

str  <EOF
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"

Now I could do a thing like

module EmptyModule
end

EmptyModule.module_eval(str)

def self.find_class mod
    mod.constants.each do |str|
      m  od.const_get(str)
        if m.class Module
          find_class(m)
        else
          cname  .to_s
          puts cname.match(/EmptyModule::/).post_match
          break
         end
       end
   end

and call this method

find_class(EmptyModule)

which prints  "A::B"

This works but it seems too much work to do something simple.

Is there a better/simpler way to do this?

Thanks
Nasir

------art_49453_8457685.1175288081423--