Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/lizarb/ruby/class.rb
Instance Method Summary collapse
- #ancestors_until(klass) ⇒ Object
- #and_descendants ⇒ Object
- #descendants ⇒ Object
- #first_namespace ⇒ Object
- #last_namespace ⇒ Object
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_descendants ⇒ Object
9 10 11 |
# File 'lib/lizarb/ruby/class.rb', line 9 def and_descendants ObjectSpace.each_object(Class).select { |klass| klass <= self } end |
#descendants ⇒ Object
5 6 7 |
# File 'lib/lizarb/ruby/class.rb', line 5 def descendants ObjectSpace.each_object(Class).select { |klass| klass < self } end |
#first_namespace ⇒ Object
17 18 19 |
# File 'lib/lizarb/ruby/class.rb', line 17 def first_namespace name.rpartition('::')[0] end |
#last_namespace ⇒ Object
21 22 23 |
# File 'lib/lizarb/ruby/class.rb', line 21 def last_namespace name.rpartition('::')[-1] end |