74ellw
3.889K
· November 2012 ·
E3e5923c7e2954158e9b9b0493c9132c

List only instance methods that you defined in a class

Get all instance methods of your class
By passing false you will get instance method defined by you not the inherited by parent class
So if you do like :



class Blog
def initialize(title)
@title = title
end
def article
@title
end
end
</pre>
</code>


@blog = Blog.new('post1')
@blog.class.instance_methods(false) => [:article]
</pre>
</code>

It will only show up #article

Sign in or sign up to add your response.

1 Response

1271
Ea5faeebdabb2d5ed56e027246424d0d

THANKS! THIS WAS REALLY HELPFUL.

over 1 year ago ·
Featured Programming Job

Test Lead
·
Toronto
·
Full Time
Search all programming jobs