I am using interactive Ruby for quick testing my swigged c++ module. In
python i can write down the command dir(), and I will get what`s inside
the module. Is there a similar function for Ruby ?
Hi,
···
At Wed, 28 Jan 2004 19:54:53 +0900, Asbjørn Reglund Thorsen wrote:
I am using interactive Ruby for quick testing my swigged c++ module. In
python i can write down the command dir(), and I will get what`s inside
the module. Is there a similar function for Ruby ?
$ ri instance_methods
------------------------------------------------ Module#instance_methods
mod.instance_methods(include_super=false) => array
Returns an array containing the names of public instance methods in
the receiver. For a module, these are the public 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
end
class B
def method2() end
end
class C < B
def method3() end
end
A.instance_methods #=> ["method1"]
B.instance_methods #=> ["method2"]
C.instance_methods #=> ["method3"]
C.instance_methods(true).length #=> 43
A.instance_methods #=> ["method1"]
B.instance_methods #=> ["method2"]
C.instance_methods #=> ["method3"]
C.instance_methods(true).length #=> 43
–
Nobu Nakada
better ![]()
IIRC dir() will give you all the atributes, both functionsn constants
and so on. In ruby you may be more specific with
Module.instance_methods
public_methods
private_instance_methods
constants
and so on ![]()
···
il Wed, 28 Jan 2004 11:52:35 +0100, Asbjørn Reglund Thorsen asbjoert@ifi.uio.no ha scritto::
I am using interactive Ruby for quick testing my swigged c++ module. In
python i can write down the command dir(), and I will get what`s inside
the module. Is there a similar function for Ruby ?