查看可用的方法 ruby [英] View available methods ruby
本文介绍了查看可用的方法 ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 ruby 中查看对象的所有可用方法.当我输入 File 时,我正在使用 aptana IDE.不显示任何方法.我来自 eclipse/java 背景.
how can I view all the available methods on an object in ruby. I'm using the aptana IDE when I type File. no methods are displayed. I'm coming from an eclipse/java background.
谢谢
推荐答案
有几种方法:
obj.methods
obj.public_methods
obj.private_methods
obj.protected_methods
obj.singleton_methods
更新
要将对象方法与所有继承的方法区分开来,您可以执行以下操作:
To get the object methods apart from all inherited methods you can do:
obj.methods(false)
obj.methods(false)
正如 Tempus 在评论中提到的,以下命令对于从 Object(基类)继承的方法中获取当前对象方法非常有帮助:
As Tempus mentioned in the comments, the following command is very helpful to get the current object methods apart from the Object(base class) inherited methods:
obj.methods - Object.methods
obj.methods - Object.methods
这篇关于查看可用的方法 ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文