class method
File.path
(::string | ::_ToPath path) -> ::String
File.path(path) → string
file.c
View on GitHub ↗
static VALUE
rb_file_s_path(VALUE klass, VALUE fname)
{
return rb_get_path(fname);
}
Example
Returns the string representation of the path File.path(File::NULL) #=> "/dev/null" File.path(Pathname.new("/tmp")) #=> "/tmp"
If path is not a String:
-
If it has the
to_pathmethod, that method will be called to coerce to aString. -
Otherwise, or if the coerced result is not a
Stringtoo, the standard coersion usingto_strmethod will take place on that object. (See alsoString.try_convert)
The coerced string must satisfy the following conditions:
-
It must be in an ASCII-compatible encoding; otherwise, an
Encoding::CompatibilityErroris raised. -
It must not contain the NUL character (
\0); otherwise, anArgumentErroris raised.