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:



1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
# File 'eval.c', line 1980

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