Where developers come to connect, share, build and be inspired.

19

List only instance methods that you defined in a class

3356 views

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
@blog = Blog.new('post1')
@blog.class.instance_methods(false) => [:article]

It will only show up #article

Comments

Add a comment