开发者

Does Ruby provide the namespace path, e.g. something like [:A,:B] for class A::B::C?

Is the following possible?

puts A::B::C.new.namespace_path # => [:A,:B], or even 开发者_如何学Python[A,B]


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("::")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜