Calls the constructed Function
, with args
. Caller must ensure the underlying function is called in a thread-safe manner if running in a multi-threaded process.
For an example see Fiddle::Function
Constructs a Function
object.
ptr
is a referenced function, of a Fiddle::Handle
args
is an Array of arguments, passed to the ptr
function
ret_type
is the return type of the function
abi
is the ABI of the function
Returns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined.
module A refine Object do end end module B refine Object do end end using A using B p Module.used_modules
produces:
[B, A]
Invokes Module.prepend_features
on each parameter in reverse order.
Import class refinements from module into the current class or module definition.
Registers filename to be loaded (using Kernel::require
) the first time that module (which may be a String
or a symbol) is accessed in the namespace of mod.
module A end A.autoload(:B, "b") A::B.doit # autoloads "b"
Returns filename to be loaded if name is registered as autoload
in the namespace of mod.
module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b"
Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features
if your code wants to perform some action when a module is included in another.
module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable"
Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features
if your code wants to perform some action when a module is included in another.
module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable"
Case Equality—Returns true
if obj is an instance of mod or an instance of one of mod’s descendants. Of limited use for modules, but can be used in case
statements to classify objects by class.
Equality — At the Object
level, ==
returns true
only if obj
and other
are the same object. Typically, this method is overridden in descendant classes to provide class-specific meaning.
Unlike ==
, the equal?
method should never be overridden by subclasses as it is used to determine object identity (that is, a.equal?(b)
if and only if a
is the same object as b
):
obj = "a" other = obj.dup obj == other #=> true obj.equal? other #=> false obj.equal? obj #=> true
The eql?
method returns true
if obj
and other
refer to the same hash key. This is used by Hash
to test members for equality. For objects of class Object
, eql?
is synonymous with ==
. Subclasses normally continue this tradition by aliasing eql?
to their overridden ==
method, but there are exceptions. Numeric
types, for example, perform type conversion across ==
, but not across eql?
, so:
1 == 1.0 #=> true 1.eql? 1.0 #=> false
Comparison—Returns -1, 0, +1 or nil depending on whether module
includes other_module
, they are the same, or if module
is included by other_module
.
Returns nil
if module
has no relationship with other_module
, if other_module
is not a module, or if the two values are incomparable.
Returns true if mod is a subclass of other. Returns nil
if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “A < B”.)
Returns true if mod is a subclass of other or is the same as other. Returns nil
if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “A < B”.)
Returns true if mod is an ancestor of other. Returns nil
if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “B > A”.)
Returns true if mod is an ancestor of other, or the two modules are the same. Returns nil
if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A < B” implies “B > A”.)
Returns the name of the module mod. Returns nil for anonymous modules.
The first form is equivalent to attr_reader
. The second form is equivalent to attr_accessor(name)
but deprecated. The last form is equivalent to attr_reader(name)
but deprecated.
Creates a new anonymous module. If a block is given, it is passed the module object, and the block is evaluated in the context of this module like module_eval
.
fred = Module.new do def meth1 "hello" end def meth2 "bye" end end a = "my string" a.extend(fred) #=> "my string" a.meth1 #=> "hello" a.meth2 #=> "bye"
Assign the module to a constant (name starting uppercase) if you want to treat it like a regular module.
With no arguments, sets the default visibility for subsequently defined methods to public. With arguments, sets the named methods to have public visibility. String arguments are converted to symbols.
With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility. String arguments are converted to symbols.
module Mod def a() end def b() end private def c() end private :a end Mod.private_instance_methods #=> [:a, :c]
Note that to show a private method on RDoc
, use :doc:
.
Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features
if your code wants to perform some action when a module is included in another.
module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable"
Removes the method identified by symbol from the current class. For an example, see Module.undef_method
. String arguments are converted to symbols.