2012-06-07 12:09:13 -04:00
|
|
|
class V8::Array < V8::Object
|
2012-06-08 10:10:49 -04:00
|
|
|
|
|
|
|
def initialize(native_or_length = nil)
|
2012-06-12 08:06:25 -04:00
|
|
|
super do
|
|
|
|
if native_or_length.is_a?(Numeric)
|
|
|
|
V8::C::Array::New(native_or_length)
|
|
|
|
elsif native_or_length.is_a?(V8::C::Array)
|
|
|
|
native_or_length
|
|
|
|
else
|
|
|
|
V8::C::Array::New()
|
|
|
|
end
|
2012-06-08 10:10:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-07 12:09:13 -04:00
|
|
|
def each
|
|
|
|
@context.enter do
|
2012-06-07 12:40:53 -04:00
|
|
|
0.upto(@native.Length() - 1) do |i|
|
2012-06-07 12:09:13 -04:00
|
|
|
yield @context.to_ruby(@native.Get(i))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def length
|
|
|
|
@native.Length()
|
|
|
|
end
|
|
|
|
end
|