Mark Hubbart wrote:
(obj.methods - Object.new.methods).sort
I added that to my .irbrc file defined as Object#less_methods.
You can use Object.instance_methods instead, since
Object.instance_methods == Object.new.methods
Maybe this would be convenient:
class Object
def less_methods(cl=Object)
methods - cl.instance_methods
end
end
Great idea a quick hack now has turned into something better:
class Object
def less_methods(klass = Object)
(methods - klass.instance_methods).sort
end
end
class Class
def less_methods(klass = Class)
(methods - klass.methods).sort
end
end
class Module
def less_methods
(methods - Module.methods).sort
end
end
cheers,
–Mark
···
On Apr 25, 2004, at 12:06 PM, Joel VanderWerf wrote:
3.less_methods(Numeric)
=>[“%”, “<<”, “>>”, “prec_i”, “&”, “to_sym”, “*”, “+”, “times”,
“-”, “prec_f”, “/”, “upto”, “|”, “~”, “chr”, “to_i”, “succ”, “^”,
“**”, “to_f”, “prec”, “size”, “next”, “id2name”, “”, “downto”]