Module: Fakie::JavaScript
- Defined in:
- lib/fakie/java_script.rb
Class Method Summary collapse
-
.call(function, *args) ⇒ Object
Call a function against the context.
-
.context ⇒ ExecJS::ExternalRuntime::Context
ExecJS Context.
-
.eval(script) ⇒ Object
Call a function against the context.
Class Method Details
.call(function, *args) ⇒ Object
Call a function against the context
20 21 22 |
# File 'lib/fakie/java_script.rb', line 20 def call(function, *args) context.call(function, *args) end |
.context ⇒ ExecJS::ExternalRuntime::Context
ExecJS Context
7 8 9 10 11 12 13 14 15 |
# File 'lib/fakie/java_script.rb', line 7 def context @@_js_context ||= begin require 'execjs' js_dir = File.join(File.(File.dirname(__FILE__)), 'js') source = File.open(File.join(js_dir, 'libphonenumber.js')).read source += File.open(File.join(js_dir, 'fakie.js')).read ExecJS.compile(source) end end |
.eval(script) ⇒ Object
Call a function against the context
26 27 28 |
# File 'lib/fakie/java_script.rb', line 26 def eval(script) context.eval(script) end |