1
0
Fork 0
mirror of https://github.com/rubyjs/therubyrhino synced 2023-03-27 23:21:34 -04:00

add docs for the options to open

This commit is contained in:
Charles Lowell 2009-12-02 00:46:51 -06:00
parent 5a9bb13d9f
commit 9ca6bb7374

View file

@ -45,6 +45,10 @@ module Rhino
end end
# Create a new javascript environment for executing javascript and ruby code.
# * <tt>:sealed</tt> - if this is true, then the standard objects such as Object, Function, Array will not be able to be modified
# * <tt>:with</tt> - use this ruby object as the root scope for all javascript that is evaluated
# * <tt>:java</tt> - if true, java packages will be accessible from within javascript
def initialize(options = {}) #:nodoc: def initialize(options = {}) #:nodoc:
ContextFactory.new.call do |native| ContextFactory.new.call do |native|
@native = native @native = native
@ -92,10 +96,6 @@ module Rhino
end if open? end if open?
end end
def open?
@native == J::Context.getCurrentContext() || (raise ContextError, "context must be open")
end
# Read the contents of <tt>filename</tt> and evaluate it as javascript. Returns the result of evaluating the # Read the contents of <tt>filename</tt> and evaluate it as javascript. Returns the result of evaluating the
# javascript. e.g. # javascript. e.g.
# #
@ -117,6 +117,8 @@ module Rhino
@native.factory.instruction_limit = limit @native.factory.instruction_limit = limit
end end
# Enter this context for operations. Some methods such as eval() will
# fail unless this context is open
def open def open
begin begin
@native.factory.enterContext(@native) @native.factory.enterContext(@native)
@ -126,6 +128,13 @@ module Rhino
end if block_given? end if block_given?
end end
private
def open?
@native == J::Context.getCurrentContext() || (raise ContextError, "context must be open")
end
end end
class IOReader < Java::JavaIo::Reader #:nodoc: class IOReader < Java::JavaIo::Reader #:nodoc: