Object-oriented programming

Defining a simple class

Creating the class

Define ruby objects

Initializing the class

Defining a to_s method

Creating methods for set and get attributes

Accessor and attributes

Virtual attributes

Defining operators

Objects comparasion

Define equality method


Class method

Class variables

Class instance variables

Class constants


Method visibility: public, protected, private


Methods inheritance

Method super

Inheritance class variables

Class constants inheritance

Class hierarchy

Class as object

Singleton methods and eigenclass

Ways to create singleton methods

Ways to add a custom behaviour to an instance


Module constants, paths

Constant lookup order

The list of modules searched, in the order searched
[Enclosing::Local, Enclosing, Included, Super, Object, Kernel]



Extend with module

Class and modules hierarchy, ancestors

Method lookup

Exceptions: begin, rescue, raise

Exceptions: Exception type, else, ensure

Throw and catch

Exceptions hierarchy


Ruby Koans

Ruby Koans Online

The Ruby Koans are a great way to learn about the Ruby language.