Thursday, 17 July 2014

parents

def parents(obj)
( (obj.superclass ? parents(obj.superclass) : []) << obj). reverse
end
parents(IO).inspect
# => "[IO, BasicObject, Object]"
parents(Tempfile).inspect
#=> "[Tempfile, Delegator, BasicObject, #<Class:0x007f817cff1d60>]"
view raw gistfile1.rb hosted with ❤ by GitHub

No comments:

Post a Comment