Class: Class

Inherits:
Object show all
Defined in:
lib/ruby_patch/class.rb

Instance Method Summary collapse

Instance Method Details

#childrenObject



7
8
9
10
11
# File 'lib/ruby_patch/class.rb', line 7

def children()
  posterities.select{|c|
    c.superclass == self
  }
end

#posteritiesObject



13
14
15
16
# File 'lib/ruby_patch/class.rb', line 13

def posterities()
  classes = ObjectSpace.each_object(Class)\
    .select{|c| c.ancestors.include?(self)} - [self]
end

#posterity_of?(klass) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/ruby_patch/class.rb', line 3

def posterity_of?(klass)
  self.ancestors.include?(klass)
end