views:

29

answers:

1

Is the following possible?

puts A::B::C.new.namespace_path # => [:A,:B], or even [A,B]
+1  A: 

I think maybe #ancestors is what you're looking for.

So A::B::C.ancestors

or you may just want to self.class.to_s.split("::")

Joe Martinez
`#ancestors` give me the following array `p A::B.ancestors # => [A::B, Object, Kernel, BasicObject]`. The second approach works fine, thanks!
Andrey