Class: Woods::RubyAnalyzer::MethodAnalyzer::VisibilityTracker
- Inherits:
-
Object
- Object
- Woods::RubyAnalyzer::MethodAnalyzer::VisibilityTracker
- 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
-
#current ⇒ Object
readonly
Returns the value of attribute current.
Instance Method Summary collapse
-
#initialize ⇒ VisibilityTracker
constructor
A new instance of VisibilityTracker.
-
#process_send(send_node) ⇒ Object
Process a send node that might be a visibility modifier.
Constructor Details
#initialize ⇒ VisibilityTracker
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
#current ⇒ Object (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 |