Pathname
A Pathname represents the absolute or relative name of a file. It has two distinct uses. First, it allows manipulation of the parts of a file path (extracting components, building new paths, and so on). Second, it acts as a facade for some methods in the Dir and File classes and the FileTest module, forwarding on calls for the file named by the Pathname object.
The class Pathname is part of the Ruby Standard Library, meaning it ships with Ruby but is only available to code that explicitly requires it using require "pathname".
You create a pathname with Pathname.new(path), which takes a string argument. The method Pathname.pwd returns the current working directory as a path, and the method Pathname.glob is essentially a wrapper around ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access