Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Kernel#__dir__

__dir__ → string

Returns the canonicalized absolute path of the directory of the file from which this method is called. It means symlinks in the path is resolved. If __FILE__ is nil, it returns nil. The return value equals to File.dirname(File.realpath(__FILE__)).

See also #Complex #eval #clone #exec also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0