Class: VariableDecNode

Inherits:
Node
  • Object
show all
Defined in:
lib/nodes/stmtnodes.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#value

Instance Method Summary collapse

Methods inherited from Node

#to_s

Constructor Details

#initialize(name, value) ⇒ VariableDecNode

Returns a new instance of VariableDecNode.



21
22
23
24
# File 'lib/nodes/stmtnodes.rb', line 21

def initialize(name, value)
  super(value)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



19
20
21
# File 'lib/nodes/stmtnodes.rb', line 19

def name
  @name
end

Instance Method Details

#evaluateObject



26
27
28
29
# File 'lib/nodes/stmtnodes.rb', line 26

def evaluate
  ScopeManager.add_to_current_scope(name, @value)
  self
end