from:
http://www.ruby-doc.org/core/classes/Mo ... ml#M001701
attr(symbol, writable=false) => nil
Defines a named attribute for this module, where the name is symbol.id2name, creating an instance variable (@name) and a corresponding access method to read it. If the optional writable argument is true, also creates a method called name= to set the attribute.
module Mod
attr :size, true
end
is equivalent to:
module Mod
def size
@size
end
def size=(val)
@size = val
end
end
attr_accessor(symbol, ...) => nil
Equivalent to calling ``attrsymbol, true’’ on each symbol in turn.
module Mod
attr_accessor
one, :two)
end
Mod.instance_methods.sort #=> ["one", "one=", "two", "two="]
attr_reader(symbol, ...) => nil
Creates instance variables and corresponding methods that return the value of each instance variable. Equivalent to calling ``attr:name’’ on each name in turn.
attr_writer(symbol, ...) => nil
Creates an accessor method to allow assignment to the attribute aSymbol.id2name.