Class: Rubocop::Cop::VariableInspector::VariableEntry
- Inherits:
-
Object
- Object
- Rubocop::Cop::VariableInspector::VariableEntry
- Defined in:
- lib/rubocop/cop/variable_inspector.rb
Overview
A VariableEntry represents existance of a local variable. This holds a variable declaration node, and some states of the variable.
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#used ⇒ Object
(also: #used?)
Returns the value of attribute used.
Instance Method Summary collapse
-
#initialize(node, name = nil) ⇒ VariableEntry
constructor
A new instance of VariableEntry.
- #name ⇒ Object
Constructor Details
#initialize(node, name = nil) ⇒ VariableEntry
Returns a new instance of VariableEntry.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/variable_inspector.rb', line 28 def initialize(node, name = nil) unless VARIABLE_DECLARATION_TYPES.include?(node.type) fail ArgumentError, "Node type must be any of #{VARIABLE_DECLARATION_TYPES}, " + "passed #{node.type}" end @node = node @name = name.to_sym if name @used = false end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
24 25 26 |
# File 'lib/rubocop/cop/variable_inspector.rb', line 24 def node @node end |
#used ⇒ Object Also known as: used?
Returns the value of attribute used.
25 26 27 |
# File 'lib/rubocop/cop/variable_inspector.rb', line 25 def used @used end |
Instance Method Details
#name ⇒ Object
39 40 41 |
# File 'lib/rubocop/cop/variable_inspector.rb', line 39 def name @name || @node.children.first end |