Most of my ruby notes live under my Rails notes or in my head.

Back to Languages/Ruby

Object

inspect

displays an object in some defined, human-readable form, showing instance variables.

Regex

File

Modules

Modules group together methods, classes, constants.

include

include has nothing to do with files. It references a named module currently accessible. Does not copy functions into a class, creates a reference to them. With multiple classes including, they all point to the same thing.

For some class, you can use ruby's built in Comparable mixin, and def <=>(other) to define how to compare two objects.

Iterators and Enumerable Module

AutoLoad

autoload :MyLibrary, 'mylibrary' works like require 'mylibrary' but it only loads dependencies on the first time they're used rather than during the call itself. Symbol is the classname assigned, ruby file to be loaded is found using the relative file directory location.

Useful Array Methods