26 Feb '12, 4pm
Ruby Summary: Ruby Study Notes - Best Ruby Guide, Ruby Tutorial:
Ruby Modules are similar to classes in that they hold a collection of methods, constants, and other module and class definitions. Unlike classes, you cannot create objects based on modules; instead, you specify that you want the functionality of a particular module to be added to the functionality of a class, or of a specific object. Modules serve two purposes: First they act as namespace, letting you define methods whose names will not clash with those defined elsewhere. Second, they allow you to share functionality between classes - if a class mixes in a module, that module's instance methods become available as if they had been defined in the class. They get mixed in. Observe how we use require or load . require and load take strings as their arguments. require 'motorcycle' or load 'motorcycle.rb' include takes the name of a module, in the form of a constant, as in incl...