Class: Bowline::Desktop::JS::Script
- Includes:
- Logging
- Defined in:
- lib/bowline/desktop/js.rb
Instance Attribute Summary collapse
-
#prok ⇒ Object
readonly
Returns the value of attribute prok.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#window ⇒ Object
(also: #windows)
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(window, script, prok = nil) ⇒ Script
constructor
A new instance of Script.
- #ready? ⇒ Boolean
Methods included from Logging
#debug, debug, #log_error, log_error, trace, #trace
Constructor Details
#initialize(window, script, prok = nil) ⇒ Script
Returns 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
#prok ⇒ Object (readonly)
Returns the value of attribute prok.
7 8 9 |
# File 'lib/bowline/desktop/js.rb', line 7 def prok @prok end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
7 8 9 |
# File 'lib/bowline/desktop/js.rb', line 7 def script @script end |
#window ⇒ Object (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
#call ⇒ Object
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 |
#ready? ⇒ Boolean
15 16 17 18 19 |
# File 'lib/bowline/desktop/js.rb', line 15 def ready? multiple_windows? ? windows.all?(&:loaded?) : window.loaded? end |