Skip to content

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

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
See also #path #to_io #tty? #to_i also in 4.0 · 3.4 · 3.3 · 3.2