Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method · added in Ruby 3.2

IO#path

() -> ::String?
path → string or nil

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

Ruby version changes

  1. 3.2
See also #oflush #pathconf #nonblock? #pid also in 4.0 · 3.4 · 3.3 · 3.2