Class: Bowline::Desktop::JS::Script
- Inherits:
-
Object
- Object
- Bowline::Desktop::JS::Script
- Includes:
- Logging
- Defined in:
- lib/bowline/desktop/js.rb
Instance Attribute Summary (collapse)
-
- (Object) prok
readonly
Returns the value of attribute prok.
-
- (Object) script
readonly
Returns the value of attribute script.
-
- (Object) window
(also: #windows)
readonly
Returns the value of attribute window.
Instance Method Summary (collapse)
- - (Object) call
-
- (Script) initialize(window, script, prok = nil)
constructor
A new instance of Script.
- - (Boolean) ready?
Methods included from Logging
Constructor Details
- (Script) initialize(window, script, prok = nil)
A new instance of Script
8 9 10 11 12 |
# File 'lib/bowline/desktop/js.rb', line 8 def initialize(window, script, prok = nil) @window = window @script = script @prok = prok end |
Instance Attribute Details
- (Object) prok (readonly)
Returns the value of attribute prok
7 8 9 |
# File 'lib/bowline/desktop/js.rb', line 7 def prok @prok end |
- (Object) script (readonly)
Returns the value of attribute script
7 8 9 |
# File 'lib/bowline/desktop/js.rb', line 7 def script @script end |
- (Object) window (readonly) Also known as: windows
Returns the value of attribute window
7 8 9 |
# File 'lib/bowline/desktop/js.rb', line 7 def window @window end |
Instance Method Details
- (Object) call
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bowline/desktop/js.rb', line 21 def call if Desktop.enabled? debug "JS eval on #{window}: #{script}" if multiple_windows? windows.each {|w| w.run_script(script) } raise "Can't return from multiple windows" if prok else result = parse(window.run_script(script)) Thread.new { prok.call(result) } if prok end result else debug "Pseudo JS eval on #{window}: #{script}" prok.call(nil) if prok end end |
- (Boolean) ready?
15 16 17 18 19 |
# File 'lib/bowline/desktop/js.rb', line 15 def ready? multiple_windows? ? windows.all?(&:loaded?) : window.loaded? end |