class Class
Public Instance Methods
ancestor?(klass)
click to toggle source
Check whether the class has the parent ‘klass’.
Example: Module.has_parent?(Object) #=> true
Returns: True or false
# File lib/extra_lib/core_ext/class.rb, line 18 def ancestor?(klass) ancestors[1..-1].include? klass end
Also aliased as: parent?
instances()
click to toggle source
Get all instances of this class that exist in ObjectSpace
.
Example: Module.instances #=> [Marshal, ObjectSpace, GC, Math, ...]
Returns: Array
# File lib/extra_lib/core_ext/class.rb, line 8 def instances objects = []; ObjectSpace.each_object(self) { |obj| objects << obj }; objects end