Class: Woods::RubyAnalyzer::MethodAnalyzer::VisibilityTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/ruby_analyzer/method_analyzer.rb

Overview

Tracks visibility state as we walk through class body statements.

Constant Summary collapse

VISIBILITY_METHODS =
%w[private protected public].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVisibilityTracker

Returns a new instance of VisibilityTracker.



126
127
128
# File 'lib/woods/ruby_analyzer/method_analyzer.rb', line 126

def initialize
  @current = :public
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



124
125
126
# File 'lib/woods/ruby_analyzer/method_analyzer.rb', line 124

def current
  @current
end

Instance Method Details

#process_send(send_node) ⇒ Object

Process a send node that might be a visibility modifier.



131
132
133
134
135
136
137
138
139
# File 'lib/woods/ruby_analyzer/method_analyzer.rb', line 131

def process_send(send_node)
  return unless send_node.method_name
  return unless VISIBILITY_METHODS.include?(send_node.method_name)
  # Only bare calls (no receiver, no arguments) act as section modifiers
  return if send_node.receiver
  return if send_node.arguments && !send_node.arguments.empty?

  @current = send_node.method_name.to_sym
end