mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
27 lines
No EOL
424 B
Ruby
27 lines
No EOL
424 B
Ruby
|
|
module Rhino
|
|
class NativeObject
|
|
include Enumerable
|
|
attr_reader :j
|
|
|
|
def initialize(j)
|
|
@j = j
|
|
end
|
|
|
|
def [](k)
|
|
if v = @j.get(k.to_s,@j)
|
|
v == J::Scriptable::NOT_FOUND ? nil : Context.to_ruby(v)
|
|
end
|
|
end
|
|
|
|
def []=(k,v)
|
|
@j.put(k.to_s,@j,v)
|
|
end
|
|
|
|
def each
|
|
for id in @j.getAllIds() do
|
|
yield id,@j.get(id,@j)
|
|
end
|
|
end
|
|
end
|
|
end |