O'Reilly logo

Ruby Quick Syntax Reference by Matt Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 15

image

Files and Directories

Continuing from the previous chapter, here we look at Ruby’s ability to deal with files and directories. Within a Ruby application, we may need to open files, amend those files, and write them back to a particular directory, or we may need to open a file, process this file, and move the file into another directory.

To do this we will use the File class, used in the previous chapter, along with the Dir class which is Ruby’s method of interpreting and interacting with directory paths. Many of the methods of this class have names similar to the relevant Linux command.

To start with, we can begin navigating through ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required