查看可用的方法ruby [英] View available methods ruby

查看:114
本文介绍了查看可用的方法ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看Ruby中对象的所有可用方法。当我键入文件时,我正在使用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.

谢谢

推荐答案

p>有几种方法:

obj.methods
obj.public_methods
obj.private_methods
obj.protected_methods
obj.singleton_methods

更新 / p>

Update


  1. 要使对象方法与所有继承的方法分开,您可以执行以下操作:

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆