1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/lib/v8/array.rb

25 lines
488 B
Ruby
Raw Normal View History

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