Class: Zaid::Nodes::SetLocalNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/zaid/nodes/set_local_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/zaid/nodes/set_local_node.rb', line 5

def name
  @name
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



5
6
7
# File 'lib/zaid/nodes/set_local_node.rb', line 5

def value
  @value
end

Instance Method Details

#eval(context) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/zaid/nodes/set_local_node.rb', line 6

def eval(context)
  if Constants.key?(name)
    Constants[name] = value.eval(context)
  else
    context.locals[name] = value.eval(context)
  end
end