class AClass
FILE = __FILE__
...
end
But I don't really want to have to hand insert that in every case.
T.
I don't know a built in solution but this works for classes:
class Class
def inherited(cl) cl.const_set("FILE", caller[-1].freeze) end
end
Put it at the beginning of the script (or into a file that you require
first). Then you can do
class Foo
end
p Foo::FILE
Of course you can also split the value in file name and line number etc.
Kind regards
robert
Also, you'll need to keep track of which module you're in at any given
time -- you wouldn't want to confuse Foo::Bar with Whiskey::Bar, for
example.
Something along the lines of Robert's example looks more feasible.
-rcoder