private_instance_methods

mod.private_instance_methods(include_super=true) â array Instance Public methods Returns a list of the private instance methods defined in mod. If the optional parameter is not false, the methods of any ancestors are included. module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1]

private_constant

mod.private_constant(symbol, ...) => mod Instance Public methods Makes a list of existing constants private.

private_class_method

mod.private_class_method(symbol, ...) â mod Instance Public methods Makes existing class methods private. Often used to hide the default constructor new. class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end

name

mod.name â string Instance Public methods Returns the name of the module mod. Returns nil for anonymous modules.

module_exec

mod.module_exec(arg...) {|var...| block } â obj Instance Public methods Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing.new.hello() produces: Hello there!

module_eval

mod.module_eval {|| block } â obj Instance Public methods Evaluates the string or block in the context of mod, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional filename and lineno parameters set the text for error messages. class Thing end a = %q{def hello() "Hello there!" end} Thing.module_eval(a) puts Thing.new.h

method_defined?

mod.method_defined?(symbol) â true or false Instance Public methods Returns true if the named method is defined by mod (or its included modules and, if mod is a class, its ancestors). Public and protected methods are matched. module A def method1() end end class B def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.method_defined? "method1" #=> true C.method_defined? "method2" #=> true C.method_d

instance_methods

mod.instance_methods(include_super=true) â array Instance Public methods Returns an array containing the names of the public and protected instance methods in the receiver. For a module, these are the public and protected methods; for a class, they are the instance (not singleton) methods. With no argument, or with an argument that is false, the instance methods in mod are returned, otherwise the methods in mod and mod's superclasses are returned. module A def method1() end e

instance_method

mod.instance_method(symbol) â unbound_method Instance Public methods Returns an UnboundMethod representing the given instance method in mod. class Interpreter def do_a() print "there, "; end def do_d() print "Hello "; end def do_e() print "!\n"; end def do_v() print "Dave"; end Dispatcher = { "a" => instance_method(:do_a), "d" => instance_method(:do_d), "e" => instance_method(:do_e), "v" => instance_method(:do_v) } def interpret(

inspect

inspect() Instance Public methods Alias for: to_s