Class: WebConsole::Window
- Inherits:
-
Object
- Object
- WebConsole::Window
- Defined in:
- lib/webconsole/lib/window.rb
Constant Summary collapse
- LOADHTML_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "load_html.scpt")
- LOADHTMLWITHBASEURL_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "load_html_with_base_url.scpt")
- DOJAVASCRIPT_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "do_javascript.scpt")
- CLOSEWINDOW_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "close_window.scpt")
Instance Attribute Summary collapse
-
#base_url ⇒ Object
writeonly
Sets the attribute base_url.
Instance Method Summary collapse
- #base_url_path=(value) ⇒ Object
- #close ⇒ Object
- #do_javascript(javascript) ⇒ Object
-
#initialize(window_id = nil) ⇒ Window
constructor
A new instance of Window.
- #load_html(html) ⇒ Object
- #window_id ⇒ Object
Constructor Details
#initialize(window_id = nil) ⇒ Window
Returns a new instance of Window.
7 8 9 |
# File 'lib/webconsole/lib/window.rb', line 7 def initialize(window_id = nil) @window_id = window_id end |
Instance Attribute Details
#base_url=(value) ⇒ Object (writeonly)
Sets the attribute base_url
5 6 7 |
# File 'lib/webconsole/lib/window.rb', line 5 def base_url=(value) @base_url = value end |
Instance Method Details
#base_url_path=(value) ⇒ Object
11 12 13 |
# File 'lib/webconsole/lib/window.rb', line 11 def base_url_path=(value) @base_url = "file://" + value end |
#close ⇒ Object
44 45 46 |
# File 'lib/webconsole/lib/window.rb', line 44 def close WebConsole::run_applescript(CLOSEWINDOW_SCRIPT, [window_id]) end |
#do_javascript(javascript) ⇒ Object
39 40 41 |
# File 'lib/webconsole/lib/window.rb', line 39 def do_javascript(javascript) WebConsole::run_applescript(DOJAVASCRIPT_SCRIPT, [javascript, window_id]) end |
#load_html(html) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/webconsole/lib/window.rb', line 17 def load_html(html) arguments = [html] script = LOADHTML_SCRIPT if @base_url script = LOADHTMLWITHBASEURL_SCRIPT arguments.push(@base_url) end if window_id arguments.push(window_id) end result = WebConsole::run_applescript(script, arguments) if !window_id # This allows a window manager created without a window_id and then be assigned the window_id when load_html is called. @window_id = self.class.window_id_from_result(result) end end |
#window_id ⇒ Object
48 49 50 51 52 53 |
# File 'lib/webconsole/lib/window.rb', line 48 def window_id if !@window_id && ENV.has_key?(WINDOW_ID_KEY) @window_id = ENV[WINDOW_ID_KEY] end return @window_id end |