Class: WebConsole::Window
- Inherits:
-
Object
- Object
- WebConsole::Window
- Defined in:
- lib/webconsole/lib/window.rb
Direct Known Subclasses
Constant Summary collapse
- LOADHTML_SCRIPT =
Web
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")
- READ_FROM_STANDARD_INPUT_SCRIPT =
File.join(APPLESCRIPT_DIRECTORY, "read_from_standard_input.scpt")
- CLOSEWINDOW_SCRIPT =
Window
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
Properties.
- #close ⇒ Object
- #do_javascript(javascript) ⇒ Object
-
#initialize(window_id = nil) ⇒ Window
constructor
A new instance of Window.
- #load_html(html) ⇒ Object
- #read_from_standard_input(text) ⇒ Object
- #split_id ⇒ Object
- #split_id_last ⇒ 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
Properties
13 14 15 |
# File 'lib/webconsole/lib/window.rb', line 13 def base_url_path=(value) @base_url = "file://" + value end |
#close ⇒ Object
51 52 53 |
# File 'lib/webconsole/lib/window.rb', line 51 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) run_script(DOJAVASCRIPT_SCRIPT, [javascript]) end |
#load_html(html) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/webconsole/lib/window.rb', line 25 def load_html(html) arguments = [html] script = LOADHTML_SCRIPT if @base_url script = LOADHTMLWITHBASEURL_SCRIPT arguments.push(@base_url) end run_script(script, arguments) end |
#read_from_standard_input(text) ⇒ Object
44 45 46 |
# File 'lib/webconsole/lib/window.rb', line 44 def read_from_standard_input(text) run_script(READ_FROM_STANDARD_INPUT_SCRIPT, [text]) end |
#split_id ⇒ Object
55 56 57 |
# File 'lib/webconsole/lib/window.rb', line 55 def split_id WebConsole::split_id_in_window(window_id) end |
#split_id_last ⇒ Object
59 60 61 |
# File 'lib/webconsole/lib/window.rb', line 59 def split_id_last WebConsole::split_id_in_window_last(window_id) end |
#window_id ⇒ Object
17 18 19 |
# File 'lib/webconsole/lib/window.rb', line 17 def window_id @window_id ||= ENV.has_key?(WINDOW_ID_KEY) ? ENV[WINDOW_ID_KEY] : WebConsole::create_window end |