1. Technology
Send to a Friend via Email

Object Oriented Programming

Ruby is an object oriented programming language in the purest sense of the word. Everything in Ruby is an object, and every object has a class. It's difficult to program anything but the smallest scripts without touching on object oriented programming.

Everything about Object Oriented Programming
Everything in Ruby touches object oriented programming. You can't go anywhere without seeing it. These articles should get you started in OOP with Ruby.

Object Specific Behavior
All Ruby method call lookups follow the ancestor chain. However, there are invisible entries called Singleton Classes that must be considered.

Introducing Classes
Ruby is an object oriented programming language. This means code is organized into classes, and data is manipulated via objects. Since this is so essential to Ruby, it's very easy to do.

Code Reuse: Inheritance

Using Attributes

Modules: Containment and Composition

Methods

More About Methods

Dynamic Method Calls
If you're coming from a compiled language, it's easy to think that method calls are like native function calls. This is simply not the case in Ruby.

Instantiation and the Initialize Method
Ruby objects are instantiated using the Class.new method, and initialize using their own initialize methods.

Overloading Operators
Ruby allows you to overload operators, so expressions like a + b can work no matter what the types of a or b are.

Method Visibility
Method visibility is an important part of object oriented programming. Not only does it hide dangerous and unnecessary methods from the user, but it communicates to them that such methods are not even worth learning.

You can opt-out at any time. Please refer to our privacy policy for contact information.

©2014 About.com. All rights reserved.