Class: Looksee::Adapter::Base
- Inherits:
-
Object
- Object
- Looksee::Adapter::Base
- Defined in:
- lib/looksee/adapter/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#describe_module(mod) ⇒ Object
Return a description of the given module.
- #internal_class(object) ⇒ Object
- #internal_class_to_module(internal_class) ⇒ Object
- #internal_private_instance_methods(mod) ⇒ Object
- #internal_protected_instance_methods(mod) ⇒ Object
- #internal_public_instance_methods(mod) ⇒ Object
- #internal_superclass(klass) ⇒ Object
- #internal_undefined_instance_methods(mod) ⇒ Object
-
#lookup_modules(object) ⇒ Object
Return the chain of classes and modules which comprise the object’s method lookup path.
- #module_name(mod) ⇒ Object
- #singleton_class?(object) ⇒ Boolean
- #singleton_instance(singleton_class) ⇒ Object
- #source_location(method) ⇒ Object
Instance Method Details
#describe_module(mod) ⇒ Object
Return a description of the given module.
This is used for the module labels in the Inspector output.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/looksee/adapter/base.rb', line 23 def describe_module(mod) num_brackets = 0 object = mod while singleton_class?(object) num_brackets += 1 object = singleton_instance(object) end if object.is_a?(Module) description = module_name(object) if description.empty? description = "unnamed #{object.is_a?(Class) ? 'Class' : 'Module'}" end else description = "#{module_name(object.class)} instance" end if num_brackets == 0 description else "#{'['*num_brackets}#{description}#{']'*num_brackets}" end end |
#internal_class(object) ⇒ Object
51 52 53 |
# File 'lib/looksee/adapter/base.rb', line 51 def internal_class(object) raise NotImplementedError, "abstract" end |
#internal_class_to_module(internal_class) ⇒ Object
55 56 57 |
# File 'lib/looksee/adapter/base.rb', line 55 def internal_class_to_module(internal_class) raise NotImplementedError, "abstract" end |
#internal_private_instance_methods(mod) ⇒ Object
67 68 69 |
# File 'lib/looksee/adapter/base.rb', line 67 def internal_private_instance_methods(mod) raise NotImplementedError, "abstract" end |
#internal_protected_instance_methods(mod) ⇒ Object
63 64 65 |
# File 'lib/looksee/adapter/base.rb', line 63 def internal_protected_instance_methods(mod) raise NotImplementedError, "abstract" end |
#internal_public_instance_methods(mod) ⇒ Object
59 60 61 |
# File 'lib/looksee/adapter/base.rb', line 59 def internal_public_instance_methods(mod) raise NotImplementedError, "abstract" end |
#internal_superclass(klass) ⇒ Object
47 48 49 |
# File 'lib/looksee/adapter/base.rb', line 47 def internal_superclass(klass) raise NotImplementedError, "abstract" end |
#internal_undefined_instance_methods(mod) ⇒ Object
71 72 73 |
# File 'lib/looksee/adapter/base.rb', line 71 def internal_undefined_instance_methods(mod) raise NotImplementedError, "abstract" end |
#lookup_modules(object) ⇒ Object
Return the chain of classes and modules which comprise the object’s method lookup path.
8 9 10 11 12 13 14 15 16 |
# File 'lib/looksee/adapter/base.rb', line 8 def lookup_modules(object) modules = [] klass = internal_class(object) while klass modules << internal_class_to_module(klass) klass = internal_superclass(klass) end modules end |
#module_name(mod) ⇒ Object
83 84 85 |
# File 'lib/looksee/adapter/base.rb', line 83 def module_name(mod) raise NotImplementedError, "abstract" end |
#singleton_class?(object) ⇒ Boolean
75 76 77 |
# File 'lib/looksee/adapter/base.rb', line 75 def singleton_class?(object) raise NotImplementedError, "abstract" end |
#singleton_instance(singleton_class) ⇒ Object
79 80 81 |
# File 'lib/looksee/adapter/base.rb', line 79 def singleton_instance(singleton_class) raise NotImplementedError, "abstract" end |
#source_location(method) ⇒ Object
88 89 90 91 92 |
# File 'lib/looksee/adapter/base.rb', line 88 def source_location(method) method.is_a?(UnboundMethod) or raise TypeError, "expected UnboundMethod, got #{method.class}" method.source_location end |