I had a hard enough time recalling that #instance_methods only returns
public methods rather then all methods, and after all this time I’m
only now discovering that #methods(false) only returns singleton
methods? Why? Has it changed? Am I loosing my mind? The ri doumentation
fails even to metion the parameter. The asymmetry of these
method-methods continually wastes effort.
irb(main):001:0> class A
irb(main):002:1> def a; end
irb(main):003:1> private
irb(main):004:1> def b; end
irb(main):005:1> protected
irb(main):006:1> def c; end
irb(main):007:1> end
=> nil
irb(main):008:0> a = A.new
=> #<A:0xb7c9705c>
irb(main):009:0> def a.d; end
=> nil
irb(main):010:0> a.methods
=> [“to_a”, “respond_to?”, “type”, “protected_methods”, “eql?”,
“instance_variable_set”, “is_a?”, “hash”, “to_s”, “send”, “class”,
“tainted?”, “private_methods”, “send”, “untaint”, “a”, “id”,
“inspect”, “instance_eval”, “clone”, “public_methods”, “extend”,
“freeze”, “display”, “id”, “d”, “==”, “methods”, “method”, “===”,
“nil?”, “dup”, “instance_variables”, “instance_of?”, “object_id”, “=~”,
“c”, “singleton_methods”, “equal?”, “taint”, “frozen?”,
“instance_variable_get”, “kind_of?”]
irb(main):011:0> a.methods(false)
=> [“d”]