Class: Smacro::Collector

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/smacro.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Collector

Returns a new instance of Collector.



34
35
36
# File 'lib/smacro.rb', line 34

def initialize
  @hits = []
end

Instance Attribute Details

#hits ⇒ Object (readonly)

Returns the value of attribute hits.



32
33
34
# File 'lib/smacro.rb', line 32

def hits
  @hits
end

Instance Method Details

#visit_call_node(node) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/smacro.rb', line 38

def visit_call_node(node)
  if node.receiver.nil? && node.block.nil? && MACROS.key?(node.name)
    @hits << node # nested macros are not handled in the PoC
  else
    super
  end
end