Skip to Content
Ruby on Rails For Dummies®
book

Ruby on Rails For Dummies®

by Barry Burd
January 2007
Beginner
330 pages
6h 52m
English
Wiley
Content preview from Ruby on Rails For Dummies®

Chapter 6. Ruby Two's Day

In This Chapter

  • Discovering object‐oriented programming in 25 pages or fewer

  • Using Ruby's iterators

  • Gathering code into modules

Think about something tiny — a tiny icon on a computer's screen. Magnify the icon's image by a factor of 7 or more. What do you see?

You see dots. You see jagged edges and blurs. If you magnify by a sufficiently large factor, you don't even see the original image. What once looked like a picture of a file folder becomes a meaningless field of light and dark pixels.

If you look at an image too closely and you ignore the big picture, you're likely to miss something important. A similar thing happens when you write computer programs. If you concentrate too much on each little statement and ignore the way statements are organized into larger units, you miss some important concepts.

Objects and Classes

An object is a single thing. Here's an employee object. The employee object has a name ("Barry Burd"), a hire date (2006‐06‐21), and a salary (1000000.00). And here's a second employee object. This second object has a different name ("Harriet Ritter"), a different hire date (2006‐06‐25), and a different salary (50000.00).

A class is a blueprint. The blueprint describes each one of a bunch of similar things. The Employee class says that each employee object has a name, a hire date, and a salary. The Employee class doesn't contain any particular name (such as "Barry Burd" or "Harriet Ritter"). The Employee class doesn't contain any particular hire ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Ruby on Rails: Up and Running

Ruby on Rails: Up and Running

Bruce Tate, Curt Hibbs
Ruby on Rails® Bible

Ruby on Rails® Bible

Timothy Fisher
Learning Rails 5

Learning Rails 5

J. Mark Locklear, Eric J Gruber, Barnabas Bulpett

Publisher Resources

ISBN: 9780470081204Purchase book