Class: Class

Inherits:
Object
  • Object
show all
Defined in:
lib/lizarb/ruby/class.rb

Instance Method Summary collapse

Instance Method Details

#ancestors_until(klass) ⇒ Object



13
14
15
# File 'lib/lizarb/ruby/class.rb', line 13

def ancestors_until klass
  ancestors.take_while { _1 <= klass }
end

#and_descendantsObject



9
10
11
# File 'lib/lizarb/ruby/class.rb', line 9

def and_descendants
  ObjectSpace.each_object(Class).select { |klass| klass <= self }
end

#descendantsObject



5
6
7
# File 'lib/lizarb/ruby/class.rb', line 5

def descendants
  ObjectSpace.each_object(Class).select { |klass| klass < self }
end

#first_namespaceObject



17
18
19
# File 'lib/lizarb/ruby/class.rb', line 17

def first_namespace
  name.rpartition('::')[0]
end

#last_namespaceObject



21
22
23
# File 'lib/lizarb/ruby/class.rb', line 21

def last_namespace
  name.rpartition('::')[-1]
end