Class: ZunScript::VariableReference

Inherits:
ZValue
  • Object
show all
Defined in:
lib/zunscript/value.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope, identifier) ⇒ VariableReference

Returns a new instance of VariableReference.



45
46
47
48
# File 'lib/zunscript/value.rb', line 45

def initialize scope, identifier
  @scope = scope
  @identifier = identifier
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



50
51
52
53
# File 'lib/zunscript/value.rb', line 50

def method_missing m, *args
  # puts "identifier: #{@identifier.inspect}"
  (@scope.get @identifier).send m, *args
end

Instance Method Details

#assign(value) ⇒ Object



59
60
61
# File 'lib/zunscript/value.rb', line 59

def assign value
  return @scope.set_local @identifier, value
end

#getObject



55
56
57
# File 'lib/zunscript/value.rb', line 55

def get
  @scope.get @identifier
end

#inspectObject



63
64
65
# File 'lib/zunscript/value.rb', line 63

def inspect
  return "#<REF #{@identifier} @ #{@scope.inspect}>"
end