class Module
def nesting
a = inspect.split("::")
a.length.downto(1).to_a.map{|l| const_get(a[0, l].join("::"))}
end
end
or
class Module
def nesting
s = inspect
s.count(":")./(2).downto(0).to_a.map{|l| const_get(s[/[^:]+(?:::[^:]+){#{l}}/])}
end
end