Chapter 12. File and I/O operations

This chapter covers
  • Keyboard input and screen output
  • The IO and File classes
  • Standard library file facilities, including FileUtils and Pathname
  • The StringIO and open-uri library features

As you’ll see once you dive in, Ruby keeps even file and I/O operations object oriented. This is great for consistency—as your programs grow and begin interacting with other systems, you can fall back on your “(very nearly) everything is an object” understanding of Ruby and apply it to the utilities described in this chapter. Input and output streams, like the standard input stream or, for that matter, any file handle, are objects. Some I/O-related commands are more procedural: puts, for example, ...

Get The Well-Grounded Rubyist, Third Edition 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.