Class: Hone::Patterns::EachWithIndex::LocalVariableCollector

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/hone/patterns/each_with_index.rb

Overview

Helper visitor to collect all local variable read references

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocalVariableCollector

Returns a new instance of LocalVariableCollector.



105
106
107
# File 'lib/hone/patterns/each_with_index.rb', line 105

def initialize
  @used_names = Set.new
end

Instance Attribute Details

#used_namesObject (readonly)

Returns the value of attribute used_names.



103
104
105
# File 'lib/hone/patterns/each_with_index.rb', line 103

def used_names
  @used_names
end

Instance Method Details

#visit_local_variable_read_node(node) ⇒ Object



109
110
111
112
# File 'lib/hone/patterns/each_with_index.rb', line 109

def visit_local_variable_read_node(node)
  @used_names << node.name
  super
end