attr(...) public

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
Show source
Register or log in to add new notes.