Class: EleetScript::EleetScriptArray

Inherits:
EleetScriptClass show all
Defined in:
lib/lang/runtime/array.rb

Instance Attribute Summary collapse

Attributes inherited from EleetScriptClass

#class_vars, #context, #methods, #name, #super_class

Attributes inherited from EleetScriptClassSkeleton

#memory, #ruby_value

Instance Method Summary collapse

Methods inherited from EleetScriptClass

#call, #class_def, create, #def, #es_responds_to?, #inspect, #instance_lookup, #lookup, #new, #new_with_value, #super_call

Methods inherited from EleetScriptClassSkeleton

#class?, #eql?, #instance?, #is_a?, set_is_class, set_is_instance

Constructor Details

#initialize(memory, super_class = nil) ⇒ EleetScriptArray

Returns a new instance of EleetScriptArray.



5
6
7
8
9
# File 'lib/lang/runtime/array.rb', line 5

def initialize(memory, super_class = nil)
  super(memory, super_class)
  @hash = {}
  @array = []
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



3
4
5
# File 'lib/lang/runtime/array.rb', line 3

def array
  @array
end

#hashObject (readonly)

Returns the value of attribute hash.



3
4
5
# File 'lib/lang/runtime/array.rb', line 3

def hash
  @hash
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lang/runtime/array.rb', line 11

def to_s
  str = "<EleetScriptArray"
  hash_data = @hash.map do |key, value|
    "#{key}=#{value}"
  end
  data = @array.dup.concat(hash_data)
  if data.length > 0
    str += "[" + data.join(", ") + "]"
  end
  str + ">"
end