Forum: Ruby Path to loaded module ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jonathan D. (Guest)
on 2006-01-15 18:52
Hello,

Is there any way to get the path of a loaded module ?
I think I have two concurent versions of the same module and I can't
figure which one is loaded.

Thx,
Jonathan.
Ryan L. (Guest)
on 2006-01-17 23:35
(Received via mailing list)
Here is something to try:

def script_find(name)
  name += '.rb.' if name !~ /\.rb$/
  $LOAD_PATH.inject([]) do |result, path|
    if test(?e, File.join(path, name))
      result << path
    end
    result
  end
end
p script_find('singleton')

Ryan
This topic is locked and can not be replied to.