methods(p1) public

Returns a list of the names of public and protected methods of obj. This will include all the methods accessible in obj’s ancestors. If the regular parameter is set to false, Returns an array of obj’s public and protected singleton methods, the array will not include methods in modules included in obj.

class Klass
  def klass_method()
k = Klass.new
k.methods[0..9]    #=> [:klass_method, :nil?, :===,
                   #    :==~, :!, :eql?
                   #    :hash, :<=>, :class, :singleton_class]
k.methods.length   #=> 57

k.methods(false)   #=> []
def k.singleton_method; end
k.methods(false)   #=> [:singleton_method]

module M123; def m123; end end
k.extend M123
k.methods(false)   #=> [:singleton_method]
Show source
Register or log in to add new notes.