class

Module

v2_1_10 - Show latest stable

A Module is a collection of methods and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See Module#module_function.)

In the descriptions that follow, the parameter sym refers to a symbol, which is either a quoted string or a Symbol (such as :name).

module Mod
  include Math
  CONST = 1
  def meth
    #  ...
  end
end
Mod.class              #=> Module
Mod.constants          #=> [:CONST, :PI, :E]
Mod.instance_methods   #=> [:meth]

Core extension library

Files

  • class.c
  • eval.c
  • ext/psych/lib/psych/core_ext.rb
  • lib/minitest/spec.rb
  • lib/rake/ext/core.rb
  • load.c
  • object.c
  • proc.c
  • vm_eval.c
  • vm_method.c