From: Mark Brooks Date: 2007-05-30T05:45:28+09:00 Subject: Re: Finding files associated with objects in Ruby There is a Kernel method called "caller" that can help you here. It returns the current execution stack in the "file:line" format, so if you need to know what file a method is define in, you can use the "caller" method to show you. Mark On 5/29/07 4:25 PM, "gparsons" wrote: > This is a bit of an odd request, but does anyone know how i would find > what file Ruby is using to define an object in? For instance if i had > a few libraries in my include path and they defined the (ever useful) > classes Foo, Bar, and Baz is there anyway to find out from within ruby > that Foo is defined in the file /usr/local/lib/ruby/gems/1.8/gems/ > foo-1.0.0/lib/foo.rb or wherever? > > The best i could come up with would be a rather brute force approach > to searching through the files found in $: and this just seems > horribly slow and prone to explosions. Just wondering if someone out > there who has a better understanding of Ruby's underbelly might have a > better idea. > > /Geoff > > >