Class: RunJS::TheRubyRacer

Inherits:
Runtime
  • Object
show all
Defined in:
lib/runjs/runtimes/the_ruby_racer.rb

Direct Known Subclasses

TheRubyRhino

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

#initializeTheRubyRacer

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

Returns:

  • (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