A Scope represents a context of local variable visibility. This is a place where local variables belong to. A scope instance holds a scope node and variable entries.
# File lib/rubocop/cop/variable_force/scope.rb, line 11 def initialize(node) # Accept begin node for top level scope. unless SCOPE_TYPES.include?(node.type) || node.type == :begin fail ArgumentError, "Node type must be any of #{SCOPE_TYPES}, " "passed #{node.type}" end @node = node @variables = {} end
# File lib/rubocop/cop/variable_force/scope.rb, line 22 def ==(other) @node.equal?(other.node) end
# File lib/rubocop/cop/variable_force/scope.rb, line 45 def ancestors_of_node(target_node) ASTScanner.scan(@node) do |scanning_node, ancestor_nodes| return ancestor_nodes[1..-1] if scanning_node.equal?(target_node) end fail "Node #{target_node} is not found in scope #{@node}" end
Generated with the Darkfish Rdoc Generator 2.