Name
Module — Module class
Synopsis
A
Module
is similar to a class, except that it has
no superclass and can’t be instantiated.
Class Methods
Module::class_variables
Returns an array of class variable names.
Module::constants
Returns an array of constant names.
Module::nesting
Returns an array of classes and modules nested at the point of call.
Module::new
Creates a new anonymous module.
Instance Methods
m
<
mod
Returns
true
ifm
is a descendant ofmod
.m
<=
mod
Returns
true
ifm
is a descendant of or equal tomod
.m
<=>
mod
Returns +1 if
m
is an ancestor ofmod
, 0 ifm
is the same asmod
, and -1 ifm
is a descendant ofmod
.m
===
obj
Returns
true
ifobj
is an instance ofm
or one of its descendants.m
>
mod
Returns
true
ifm
is an ancestor ofmod
.m
>=
mod
Returns
true
ifm
is an ancestor of or equal tomod
.m
.ancestors
Returns an array of ancestors, including both classes and modules.
m
.const_defined?(
name
)
Returns
true
if the constant specified byname
is defined.m
.const_get(
name
)
Returns the value of the specified constant.
m
.const_set(
name
,
value
)
Sets the
value
of a constant.m
.constants
Returns an array of constant names.
m
.included_modules
Returns an array of names of included modules.
m
.instance_method(
name
)
Returns a
UnboundMethod
object corresponding toname
. An exception is raised if the corresponding method doesn’t exist.UnboundMethod
should be bound before invocation.unbound_plus = Fixnum.instance_method(:+) plus = unbound_plus.bind(1) p plus.call(2) # => 3 (1+2)
m
.instance_methods([ ...
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.