In Ruby 2.0.0-p0, the __dir__ variable was introduced for easy access to the directory of the file currently being executed.
__dir__
Why is __dir__ lowercase when __FILE__ is uppercase?
__FILE__
I think that is because __FILE__ is a parse-time constant whereas __dir__ is a function and returns File.dirname(File.realpath(__FILE__))
File.dirname(File.realpath(__FILE__))
For more details, see This discussion
2.1m questions
2.1m answers
60 comments
57.0k users