Skip to content
instance method · added in Ruby 3.2

IO#path

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

Returns the path associated with the IO, or nil if there is no path associated with the IO. It is not guaranteed that the path exists on the filesystem.

Example
$stdin.path # => "<STDIN>"

File.open("testfile") {|f| f.path} # => "testfile"

Ruby version changes

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