mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
cleanup the blorted README. I never did learn how to write proper rdoc
This commit is contained in:
parent
10123254da
commit
85df8548ef
1 changed files with 18 additions and 16 deletions
34
README.rdoc
34
README.rdoc
|
@ -13,27 +13,29 @@ Embed the Mozilla Rhino Javascript interpreter into Ruby
|
|||
|
||||
== SYNOPSIS:
|
||||
|
||||
1) Javascript goes into Ruby
|
||||
1. Javascript goes into Ruby
|
||||
1. Ruby Objects goes into Javascript
|
||||
1. Our shark's in the Javascript!
|
||||
|
||||
2) Ruby Objects goes into Javascript
|
||||
|
||||
3) Our shark's in the Javascript!
|
||||
|
||||
include Rhino
|
||||
# evaluate some simple javascript
|
||||
|
||||
#evaluate some simple javascript
|
||||
Rhino::Context.open do |context|
|
||||
context.evaljs("7 * 6") #=> 42
|
||||
end
|
||||
|
||||
#Evaluate a ruby function from javascript
|
||||
|
||||
Rhino::Context.open do |context|
|
||||
context.standard do |scope|
|
||||
scope.put("say", scope, function {|word, times| word * times})
|
||||
context.evaljs("say("Hello", 3)") #=> HelloHelloHello
|
||||
Rhino::Context.open do |context|
|
||||
context.evaljs("7 * 6") #=> 42
|
||||
end
|
||||
end
|
||||
|
||||
# evaluate a ruby function from javascript
|
||||
|
||||
include Rhino
|
||||
|
||||
Rhino::Context.open do |context|
|
||||
context.standard do |scope|
|
||||
scope.put("say", scope, function {|word, times| word * times})
|
||||
context.evaljs("say("Hello", 3)") #=> HelloHelloHello
|
||||
end
|
||||
end
|
||||
|
||||
== REQUIREMENTS:
|
||||
|
||||
* JRuby >= 1.3.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue