Show full path name of the ruby file when it get loaded

前端 未结 5 588
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 05:04

When reading source code, I always want to know the full path of the file when it is loaded, is there any callback method in ruby to accomplish this, or any other way to do

5条回答
  •  一整个雨季
    2020-12-10 05:24

    To get the full path of the file, you must assemble a string in the following way (where yourfileobject is an object of Ruby's File class).

    File.expand_path(File.dirname(yourfileobject)) + "/" + yourfileobject.path
    

提交回复
热议问题