Beginning Programming with Ruby

This material is copyright © 2003 Daniel Carrera, with additions and updates copyright © 2009 J. David Eisenberg. It is licensed under the Free Documentation License

The original material concentrates on the Ruby language and gives many useful hints about programming along the way. While I (Eisenberg) was using the material with a beginning programming class, I realized that I needed to shift the emphasis to “how to program” with Ruby as the vehicle. Everything from chapter 4 onwards, therefore, deviates significantly from the original tutorial.

Material with the dotted border and light background is extra material. If you are in a hurry, you can skip it and come back to read it later.

Before You Start

The Ruby Programming Language site has information about downloading and installing Ruby, help with Ruby, and books and other tutorials.


  1. The Basics

    About this Chapter

    1. First Steps
    2. More About Numbers
    3. Strings
    4. New Names for Old Things
    5. Your First Program
    6. Variables
    7. Variables (continued)
    8. Writing Good Programs
  2. Flow Control

    About this chapter

    1. Planning a Program
    2. Getting user input
    3. Conditionals
    4. Conditionals (part 2)
    5. While loops
    6. While loops (part 2)
    7. Planning a Large Program
  3. Data structures

    About this chapter

    1. Arrays
      1. Iterating through an array
      2. Constructing an array
      3. Arrays and Ranges
      4. Arrays of Strings
      5. Array Methods
    2. Hashes
  4. Files

    About this chapter

    1. Reading Files
    2. Writing Files
    3. Better-looking ouput
    4. Reading Files with while
  5. Problem-Solving

    About this chapter

    1. A Problem to Solve
    2. A Possible Solution
    3. The Second Approach
    4. A Problem to Solve Using Strings
    5. Finding the Right Methods
    6. The Methods You Need
    7. Programming Exercises
    8. Programming Exercises (2)
    9. Programming Exercises (3)
  6. Defining Your Own Methods

    About this chapter

    1. Simple Methods
    2. Methods with Parameters
    3. Parentheses and Methods
    4. Methods that Return Values
    5. Arrays as Parameters
  7. Classes and Objects

    About this chapter

    1. What is a Class?
    2. What is an Object?
    3. Creating a Class
    4. Creating an Instance
    5. Creating a Method in a Class
    6. Adding More Methods
    7. Creating Another Class
    8. Arrays of Objects
    9. Arrays of Objects (part 2)
    10. Customized Sorting