Class: Analyst::Entities::Entity
- Inherits:
-
Object
- Object
- Analyst::Entities::Entity
- Defined in:
- lib/analyst/entities/entity.rb
Direct Known Subclasses
ClassMethod, Empty, InstanceMethod, MethodCall, Module, Root, SingletonClass, SingletonMethod
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#classes ⇒ Object
TODO: should every Entity have these accessors? maybe they’re mixins…
- #full_name ⇒ Object
- #handle_send_node(node) ⇒ Object
-
#initialize(ast, parent) ⇒ Entity
constructor
A new instance of Entity.
- #inspect ⇒ Object
- #method_calls ⇒ Object
- #top_level_classes ⇒ Object
- #top_level_modules ⇒ Object
Constructor Details
#initialize(ast, parent) ⇒ Entity
Returns a new instance of Entity.
8 9 10 11 |
# File 'lib/analyst/entities/entity.rb', line 8 def initialize(ast, parent) @parent = parent @ast = ast end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/analyst/entities/entity.rb', line 6 def parent @parent end |
Instance Method Details
#classes ⇒ Object
TODO: should every Entity have these accessors? maybe they’re mixins… but would that provide any benefit?
19 20 21 22 23 24 25 |
# File 'lib/analyst/entities/entity.rb', line 19 def classes @classes ||= begin nested_classes = top_level_classes.map(&:classes).flatten namespaced_classes = top_level_modules.map(&:classes).flatten top_level_classes + nested_classes + namespaced_classes end end |
#full_name ⇒ Object
39 40 41 |
# File 'lib/analyst/entities/entity.rb', line 39 def full_name throw "Subclass #{self.class.name} must implement #full_name" end |
#handle_send_node(node) ⇒ Object
13 14 15 16 |
# File 'lib/analyst/entities/entity.rb', line 13 def handle_send_node(node) # raise "Subclass must implement handle_send_node" # abstract method. btw, this feels wrong -- send should be an entity too. but for now, whatevs. end |
#inspect ⇒ Object
43 44 45 46 47 |
# File 'lib/analyst/entities/entity.rb', line 43 def inspect "\#<#{self.class}:#{object_id} full_name=#{full_name}>" rescue "\#<#{self.class}:#{object_id}>" end |
#method_calls ⇒ Object
35 36 37 |
# File 'lib/analyst/entities/entity.rb', line 35 def method_calls @method_calls ||= contents_of_type(Entities::MethodCall) end |