Skip to the content.

dir.rb(path)

__dir__ is a built-in method in Ruby that returns the absolute path of the directory containing the source file in which it is called. It provides a convenient way to reference the current script’s directory.

Execution:

__dir__
#=> "."

Executed with Ruby 3.3.6