Method: Nesting.of
- Defined in:
- lib/nesting.rb
.of(mod) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nesting.rb', line 3 def of(mod) if nonmodule?(mod) raise TypeError, 'mod is not a class or module' end level = 0 # Special case Object as it's the namespace of all classes. return level if mod == Object level = if mod.name mod.name.split('::').count else -1 # Probably an anonymous module. end level end |