Published
- 1 min read
How do I get the parent`s class name in Ruby
The solution for this is noted below
How do I get the parent`s class name in Ruby
Solution
class Level1; end
class Level2 < Level1; end
class Level3 < Level2; end
Level1.superclass # Object
Level2.superclass # Level1
Level3.superclass # Level2
Level3.ancestors
# [Level3, Level2, Level1, Object, Kernel, BasicObject]
Try other methods by searching on the site. That is if this doesn’t work