Class: Reek::AST::ReferenceCollector
- Inherits:
-
Object
- Object
- Reek::AST::ReferenceCollector
- Defined in:
- lib/reek/ast/reference_collector.rb
Overview
Locates references to the current object within a portion of an abstract syntax tree.
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
private
Returns the value of attribute ast.
Instance Method Summary collapse
- #explicit_self_calls ⇒ Object private
- #implicit_self_calls ⇒ Object private
-
#initialize(ast) ⇒ ReferenceCollector
constructor
A new instance of ReferenceCollector.
- #num_refs_to_self ⇒ Object
Constructor Details
#initialize(ast) ⇒ ReferenceCollector
Returns a new instance of ReferenceCollector.
10 11 12 |
# File 'lib/reek/ast/reference_collector.rb', line 10 def initialize(ast) @ast = ast end |
Instance Attribute Details
#ast ⇒ Object (readonly, private)
Returns the value of attribute ast.
20 21 22 |
# File 'lib/reek/ast/reference_collector.rb', line 20 def ast @ast end |
Instance Method Details
#explicit_self_calls ⇒ Object (private)
22 23 24 |
# File 'lib/reek/ast/reference_collector.rb', line 22 def explicit_self_calls ast.each_node([:self, :super, :zsuper, :ivar, :ivasgn]) end |
#implicit_self_calls ⇒ Object (private)
26 27 28 |
# File 'lib/reek/ast/reference_collector.rb', line 26 def implicit_self_calls ast.each_node(:send).reject(&:receiver) end |
#num_refs_to_self ⇒ Object
14 15 16 |
# File 'lib/reek/ast/reference_collector.rb', line 14 def num_refs_to_self (explicit_self_calls.to_a + implicit_self_calls.to_a).size end |