mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
update README for new interface
This commit is contained in:
parent
11d42b3e3a
commit
cdb3bb2e73
1 changed files with 12 additions and 12 deletions
18
README.rdoc
18
README.rdoc
|
@ -22,28 +22,28 @@ Embed the Mozilla Rhino Javascript interpreter into Ruby
|
|||
# evaluate some simple javascript
|
||||
|
||||
Rhino::Context.open do |context|
|
||||
context.evaljs("7 * 6") #=> 42
|
||||
context.eval("7 * 6") #=> 42
|
||||
end
|
||||
|
||||
# evaluate a ruby function from javascript
|
||||
|
||||
Rhino::Context.open do |context|
|
||||
scope = context.init_standard_objects
|
||||
scope["say"] = function {|word, times| word * times}
|
||||
context.evaljs("say("Hello", 3)") #=> HelloHelloHello
|
||||
context["say"] = function {|word, times| word * times}
|
||||
context.eval("say("Hello", 3)") #=> HelloHelloHello
|
||||
end
|
||||
|
||||
# Configure your embedding setup
|
||||
|
||||
Rhino::Context.open do |context|
|
||||
# Make your standard objects (Object, String, etc...) immutable
|
||||
scope = context.init_standard_objects(:sealed => true)
|
||||
context.evaljs("Object.prototype.toString = function() {}") # this is an error!
|
||||
Rhino::Context.open(:sealed => true) do |context|
|
||||
context.eval("Object.prototype.toString = function() {}") # this is an error!
|
||||
end
|
||||
|
||||
#Turn on Java integration from javascript (probably a bad idea)
|
||||
scope = context.init_standard_objects(:java => true)
|
||||
context.evaljs("java.lang.System.exit()") #it's dangerous!
|
||||
Rhino::Context.open(:java => true) do |context|
|
||||
context.eval("java.lang.System.exit()") #it's dangerous!
|
||||
end
|
||||
|
||||
== REQUIREMENTS:
|
||||
|
||||
* JRuby >= 1.3.0
|
||||
|
|
Loading…
Reference in a new issue