Class: ExecJS::PCRuntime::ContextProcessRuntime::Context
- Inherits:
-
Runtime::Context
- Object
- Runtime::Context
- ExecJS::PCRuntime::ContextProcessRuntime::Context
- Defined in:
- lib/execjs/pcruntime/context_process_runtime.rb
Overview
implementation of ExecJS::Runtime::Context
Instance Method Summary collapse
-
#call(identifier, *args) ⇒ Object
implementation of ExecJS::Runtime:Context#call.
-
#eval(source, _options = {}) ⇒ Object
implementation of ExecJS::Runtime::Context#eval.
-
#exec(source, _options = {}) ⇒ Object
implementation of ExecJS::Runtime::Context#exec.
-
#initialize(runtime, source = '', options = {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(runtime, source = '', options = {}) ⇒ Context
Returns a new instance of Context.
19 20 21 22 23 24 |
# File 'lib/execjs/pcruntime/context_process_runtime.rb', line 19 def initialize(runtime, source = '', = {}) super # @type [JSRuntimeHandle] @runtime = runtime.create_runtime_handle source.encode('UTF-8') end |
Instance Method Details
#call(identifier, *args) ⇒ Object
implementation of ExecJS::Runtime:Context#call
45 46 47 |
# File 'lib/execjs/pcruntime/context_process_runtime.rb', line 45 def call(identifier, *args) @runtime.evaluate("(#{identifier}).apply(this, #{::JSON.generate(args)})") end |
#eval(source, _options = {}) ⇒ Object
implementation of ExecJS::Runtime::Context#eval
29 30 31 32 33 |
# File 'lib/execjs/pcruntime/context_process_runtime.rb', line 29 def eval(source, = {}) return unless /\S/.match?(source) @runtime.evaluate("(#{source.encode('UTF-8')})") end |
#exec(source, _options = {}) ⇒ Object
implementation of ExecJS::Runtime::Context#exec
38 39 40 |
# File 'lib/execjs/pcruntime/context_process_runtime.rb', line 38 def exec(source, = {}) @runtime.evaluate("(()=>{#{source.encode('UTF-8')}})()") end |