I wants to know the ruby's methods' describe,the relationship between
them,also the mechanism(most wants to know).
what are
methods:
public_methods:
protected_methods:
private_methods:
···
-----------------------------------------------------------------------------
#e.g(from ruby API 1.9.2)
mod.instance_methods(include_super=true) → array
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.
mod.public_instance_methods(include_super=true) → array
Returns a list of the public instance methods defined in mod. If the
optional parameter is not false, the methods of any ancestors are
included.
mod.protected_instance_methods(include_super=true) → array
Returns a list of the protected instance methods defined in mod. If the
optional parameter is not false, the methods of any ancestors are
included.
mod.private_instance_methods(include_super=true) → array
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.
-----------------------------------------------------------------------------
obj.singleton_methods(all=true) → array
Returns an array of the names of singleton methods for obj. If the
optional all parameter is true, the list will include methods in modules
included in obj. Only public and protected singleton methods are
returned.
what's the relationship between these methods?
#e.g.
String.instance_methods == "str".methods #true
String.methods(false) == String.singleton_methods(false) #true
class method is the singleton method?
.....
......
.......
I wants to know the ruby's methods' describe,the relationship between
them,also the mechanism(most wants to know).
who can Explain?
thanks...
--
Posted via http://www.ruby-forum.com/.