Class: GetThemAll::JavascriptLoader
- Inherits:
-
Object
- Object
- GetThemAll::JavascriptLoader
- Defined in:
- lib/get_them_all/javascript_loader.rb
Defined Under Namespace
Instance Method Summary collapse
- #eval(str) ⇒ Object
-
#initialize(source) ⇒ JavascriptLoader
constructor
A new instance of JavascriptLoader.
Constructor Details
#initialize(source) ⇒ JavascriptLoader
Returns a new instance of JavascriptLoader.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/get_them_all/javascript_loader.rb', line 45 def initialize(source) @context = V8::Context.new do |ctx| ctx[:document] = DOM.new() ctx[:window] = DOM.new() ctx[:jQuery] = JQuery.new ctx['setInterval'] = ctx[:window].method(:setInterval) ctx['setTimeout'] = ctx[:window].method(:setTimeout) end @context.eval(%{ $ = function(){ return document; }; $.cookie = function(){}; $.each = function(){}; // hash method cannot be defined on ruby side... window.location.hash = window; }) @context.eval(source) end |
Instance Method Details
#eval(str) ⇒ Object
69 70 71 |
# File 'lib/get_them_all/javascript_loader.rb', line 69 def eval(str) @context.eval(str) end |