Class: Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/sdx/vm/variables.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val, type, scope) ⇒ Variable

Returns a new instance of Variable.



5
6
7
8
9
# File 'lib/sdx/vm/variables.rb', line 5

def initialize(val, type, scope)
    @value = val
    @type = type
    @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



3
4
5
# File 'lib/sdx/vm/variables.rb', line 3

def scope
  @scope
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/sdx/vm/variables.rb', line 3

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/sdx/vm/variables.rb', line 3

def value
  @value
end

Instance Method Details

#set(val) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/sdx/vm/variables.rb', line 11

def set(val)
    if @mut == true 
        @value = val
    else
        puts "cant change value of immutable" # add error handling
    end
end