O'Reilly logo

The Ruby Programming Language by David Flanagan, Yukihiro Matsumoto

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 9. The Ruby Platform

image with no caption

Ruby’s core library defines a rich and powerful API that serves as a platform on which to create your programs. It is well worth your time to study and master this API, particularly the key classes such as String, Array, Hash, Enumerable, and IO. If you aren’t familiar with the methods defined by these classes, you may end up spending time reinventing functionality that is already provided for you.

This chapter documents those methods. It is not a comprehensive API reference, but attempts to illustrate, with short code snippets, the use of the important methods of all the important core classes and modules, and a few of the most commonly used classes from the standard library. The aim is to familiarize you with the broad range of existing methods, so that when you need one of them, you will remember that it exists and will be able to find its documentation with ri.

This is a long chapter, broken down into sections that cover the following:

  • Strings and text processing

  • Regular expressions

  • Numbers and math

  • Dates and times

  • The Enumerable module and the Array, Hash and Set collections

  • Input/output and files

  • Networking

  • Threads and concurrency

You’ll find that the code early in the chapter takes the form of one-line snippets demonstrating individual methods. Toward the end, however, when documenting networking and threads, the examples become longer and demonstrate how ...

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