FileUtils
In addition to the functionality in File, Ruby has an entire module called FileUtils that defines many module level methods that are basically wrappers around operating system features or Dir and File features.
To use these methods, you need to use require "fileutils". All the methods here are defined as module methods and as instance methods, though you would typically use them as module methods, as in FileUtils.mkdir.
Methods in FileUtils that take paths expect either a string, an object with a to_path method, or an object with a to_str method. Methods in FileUtils that are described as working recursively can take directories as arguments and act on all files in the directory.
Let’s take a quick tour of the FileUtils.
Common Arguments ...
Get Programming Ruby 3.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.