Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#readlink
() -> untyped
readlink → new_pathname
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1781
def readlink() self.class.new(File.readlink(@path)) end
Returns a new pathname containing the path stored in the symbolic link entry at the path stored in self:
Example
file_pn = Pathname('doc/maintainers.md') link_pn = Pathname('/tmp/link') link_pn.make_symlink(file_pn) link_pn.readlink # => #<Pathname:doc/maintainers.md> link_pn.delete # Clean up.
Raises Errno::EINVAL if the path in self is not the path to a symbolic link.
See also
#readlines
#realdirpath
#readable_real?
#realpath
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0