Class: RunJS::TheRubyRacer
- Inherits:
-
Runtime
show all
- Defined in:
- lib/runjs/runtimes/the_ruby_racer.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Runtime
#apply, #call, class_name, deprecated?, #eval
Methods included from Encoding
#encode
Constructor Details
Returns a new instance of TheRubyRacer.
14
15
16
17
|
# File 'lib/runjs/runtimes/the_ruby_racer.rb', line 14
def initialize
require lib
@context = lib_module::Context.new
end
|
Class Method Details
.available? ⇒ Boolean
7
8
9
10
11
12
|
# File 'lib/runjs/runtimes/the_ruby_racer.rb', line 7
def self.available?
require @lib
true
rescue LoadError
false
end
|
Instance Method Details
#context(js) ⇒ Object
19
20
21
22
23
|
# File 'lib/runjs/runtimes/the_ruby_racer.rb', line 19
def context(js)
js = encode(js, 'UTF-8')
context_eval(js)
self
end
|
#run(js) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/runjs/runtimes/the_ruby_racer.rb', line 25
def run(js)
js = encode(js, 'UTF-8')
js = merge_runner(js)
result = context_eval(js)
parse_json(result, js)
end
|