Class: ExecJS::Runtime
- Inherits:
-
Object
show all
- Defined in:
- lib/execjs/runtime.rb
Overview
Abstract base class for runtimes
Defined Under Namespace
Classes: Context
Instance Method Summary
collapse
Instance Method Details
#available? ⇒ Boolean
65
66
67
|
# File 'lib/execjs/runtime.rb', line 65
def available?
raise NotImplementedError
end
|
#compile(source, options = {}) ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/execjs/runtime.rb', line 53
def compile(source, options = {})
if context_class.instance_method(:initialize).arity == 2
context_class.new(self, source)
else
context_class.new(self, source, options)
end
end
|
#context_class ⇒ Object
29
30
31
|
# File 'lib/execjs/runtime.rb', line 29
def context_class
self.class::Context
end
|
#deprecated? ⇒ Boolean
61
62
63
|
# File 'lib/execjs/runtime.rb', line 61
def deprecated?
false
end
|
#eval(source, options = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/execjs/runtime.rb', line 43
def eval(source, options = {})
context = compile("", options)
if context.method(:eval).arity == 1
context.eval(source)
else
context.eval(source, options)
end
end
|
#exec(source, options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/execjs/runtime.rb', line 33
def exec(source, options = {})
context = compile("", options)
if context.method(:exec).arity == 1
context.exec(source)
else
context.exec(source, options)
end
end
|
#name ⇒ Object
25
26
27
|
# File 'lib/execjs/runtime.rb', line 25
def name
raise NotImplementedError
end
|