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
654 B
Ruby
Raw Normal View History

2009-12-15 00:35:55 -05:00
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
2009-12-16 08:03:57 -05:00
source = V8::C::String.new(javascript.to_s)
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
2009-12-15 00:35:55 -05:00
end
end