From: 7stud -- Date: 2007-11-12T15:27:17+09:00 Subject: Re: Getting methods defined in the top scope Thilina Buddhika wrote: > > I am trying to get the names of the methods defined by myself in the top > scope. I tried it by using > " self.class.private_instance_methods(false).sort " > > But it gives two additional methods given below. > inherited > initialize > > > but i want to get only the methods defined by my self. Is there any way > to solve this ? > > thanks! > > regards, > buddhika def hello end def goodbye end class Dog end value = 10 #--------- p Object.private_instance_methods(false) --->["goodbye", "initialize", "hello"] #No inherited method anywhere. method_names = Object.private_instance_methods(false) my_methods = [] method_names.each do |meth_name| if meth_name == 'initialize' or meth_name == 'inherited' next end my_methods << meth_name end p my_methods -->["goodbye", "hello"] -- Posted via http://www.ruby-forum.com/.