Class: Rubocop::Cop::VariableInspector::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/variable_inspector.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Scope

Returns a new instance of Scope.



50
51
52
53
54
55
56
57
58
59
# File 'lib/rubocop/cop/variable_inspector.rb', line 50

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
  @variable_entries = {}
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



48
49
50
# File 'lib/rubocop/cop/variable_inspector.rb', line 48

def node
  @node
end

#variable_entriesObject (readonly)

Returns the value of attribute variable_entries.



48
49
50
# File 'lib/rubocop/cop/variable_inspector.rb', line 48

def variable_entries
  @variable_entries
end