Class: RunJS::Runtime

Inherits:
Object
  • Object
show all
Includes:
Encoding
Defined in:
lib/runjs/runtime.rb

Direct Known Subclasses

SystemRuntime, TheRubyRacer

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Encoding

#encode

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/runjs/runtime.rb', line 16

def self.available?
  false
end

.class_nameObject



20
21
22
# File 'lib/runjs/runtime.rb', line 20

def self.class_name
  name.split('::').last
end

.deprecated?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/runjs/runtime.rb', line 12

def self.deprecated?
  @deprecated ||= false
end

Instance Method Details

#apply(function, this, *args) ⇒ Object



36
37
38
39
40
# File 'lib/runjs/runtime.rb', line 36

def apply(function, this, *args)
  this = 'null' if this.nil?
  args = args.to_json
  run("return #{function}.apply(#{this}, #{args});")
end

#call(function, *args) ⇒ Object



32
33
34
# File 'lib/runjs/runtime.rb', line 32

def call(function, *args)
  apply(function, 'this', *args)
end

#context(js) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/runjs/runtime.rb', line 24

def context(js)
  raise NotImplementedError
end

#eval(js) ⇒ Object



42
43
44
45
# File 'lib/runjs/runtime.rb', line 42

def eval(js)
  js = js.to_json
  run("return eval(#{js});")
end

#run(js) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/runjs/runtime.rb', line 28

def run(js)
  raise NotImplementedError
end