Method: CodeDefineInstruction#derive

Defined in:
lib/instructions/code/code_define.rb

#deriveObject



19
20
21
22
23
24
25
26
27
# File 'lib/instructions/code/code_define.rb', line 19

def derive
  if @context.variables.keys.include?(@ref)
    raise InstructionMethodError, "#{self.class.to_nudgecode} cannot change the value of a variable"
  else
    new_value = NudgeProgram.new(@code).linked_code
    raise InstructionMethodError, "#{self.class.to_nudgecode} cannot parse '#{@code}'" if new_value.is_a?(NilPoint)
    @context.names[@ref] = new_value
  end
end