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

31 lines
No EOL
649 B
Ruby

module V8
# This doesn't do anything at the moment. But the ruby interface will go here
# The native interface is under the V8::C module.
class Context
def initialize
@native = C::Context.new
end
def open(&block)
@native.open do
block.call(self) if block
end if block_given?
end
def eval(javascript)
self.open do
source = V8::C::String.new(javascript)
script = V8::C::Script.new(source)
script.Run()
end
end
def evaluate(*args)
self.eval(*args)
end
def self.open(&block)
new.open(&block)
end
end
end