Method: Kernel#__dir__

Defined in:
eval.c

#__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__)).

Returns:



2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
# File 'eval.c', line 2032

static VALUE
f_current_dirname(VALUE _)
{
    VALUE base = rb_current_realfilepath();
    if (NIL_P(base)) {
        return Qnil;
    }
    base = rb_file_dirname(base);
    return base;
}