The module class.
This method is mainly used for comparison within case statements. Returns true if obj has an Object#kind_of? relationship with self. In other words, case can be used to check the owner relationship of classes and modules.
str = String.new case str when String # evaluates String === str p true # => true end
Defines both the read and write methods for the attribute name, where name is specified by Symbol or a string.
The definition of the method defined by attr_accessor is as follows:
def name @name end def name=(val) @name = val end
Defines the read method for the attribute name, where name is specified by Symbol or a string.
The definition of the method defined by attr_reader is as follows:
def name @name end
Defines the write method for the attribute name (name=), where name is specified by Symbol or a string.
The definition of the method defined by attr_writer is as follows:
def name=(val) @name = val end
Includes the specified modules' properties (methods and constants). Returns self. include is used to implement a mix-in in place of a multiple inheritance.
class C include FileTest include Math end
Module capabilities are included by inserting modules into a class inheritance. Therefore, when searching for methods, included modules will be given priority over superclasses.
If the same module is included two or more times, the second and later instances will be ignored. Furthermore, executing an include that results in a recursive module inheritance will throw an ArgumentError exception.