Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
IO#to_path
to_path
io.c
View on GitHub ↗
VALUE
rb_io_path(VALUE io)
{
rb_io_t *fptr = RFILE(io)->fptr;
if (!fptr)
return Qnil;
return rb_obj_dup(fptr->pathv);
}
Alias of #path
Returns the string path associated with self, or nil if there is no associated path:
Example
path = 'doc/maintainers.md' fd = File.open(path).fileno # => 6 IO.new(fd, path: path).path # => "doc/maintainers.md" IO.new(fd).path # => nil