On Mon, 10 Nov 2003 12:44:05 +0100, Simon Strandgaard wrote:

> How do I obtain an Array of methods?  
> So that I get 'test1' and 'test2' returned ?
> 
> Is it the right class I have installed #debug inside?
> Perhaps it should it be Module or Class ?
 

Solved.. I wasn't aware of the #public_instance_methods .. now I am.

--
Simon Strandgaard


server> ruby a.rb
["dup", "hash", "private_methods", "nil?", "tainted?", "class", "singleton_methods", "=~", "__send__", "untaint", "instance_eval", "extend", "kind_of?", "object_id", "instance_variable_get", "test1", "inspect", "frozen?", "taint", "id", "public_methods", "to_a", "equal?", "respond_to?", "clone", "protected_methods", "display", "method", "freeze", "instance_variable_set", "type", "is_a?", "methods", "test2", "send", "instance_of?", "==", "instance_variables", "__id__", "eql?", "===", "to_s"]
42
server> expand -t2 a.rb 
class Object
  def self.debug(*args)
    p public_instance_methods
  end
end

class Test
  def test1
    puts "42"
  end
  def test2
    puts "666"
  end
  debug :test1
end

Test.new.test1
server>