Reputation: 32120
if class C < B
and class B < A
is there a command to know that C inherits B which inherits A?
Upvotes: 1
Views: 62
Reputation: 35806
You can use is_a?
to test if an object inherited from a class.
class A
end
class B < A
end
b = B.new
b.is_a? B # true
b.is_a? A # true
Upvotes: 1
Reputation: 230286
Are you looking for this?
class A; end
class B < A; end
class C < B; end
C.ancestors # => [C, B, A, Object, Kernel, BasicObject]
Upvotes: 3
Reputation: 510
class A; end
class B < A; end
class C < B; end
C.superclass # => B
C.superclass.superclass # => A
Upvotes: 1