Class: Osascript::Safari
- Inherits:
-
Object
- Object
- Osascript::Safari
- Defined in:
- lib/osascript/Safari.rb
Class Method Summary collapse
- .document_source_code ⇒ Object
- .document_text ⇒ Object
-
.get_url(options = nil) ⇒ Object
tab (for instance : options = ‘tab 2 of window 1’).
-
.open_url(url, options = nil) ⇒ Object
Open URL
urlin front document or a new window ifoptions[new_window]is true. -
.run_javascript(code, options = nil) ⇒ Object
Run a javascript code in the front document or the
options[:where]tab. -
.window_name(options = nil) ⇒ Object
The name of the front document.
Class Method Details
.document_source_code ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/osascript/Safari.rb', line 85 def document_source_code ||= {} where = [:where] || 'front document' code = " if count of window is 0\n return null\n else\n return source of (\#{where})\n end\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |
.document_text ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/osascript/Safari.rb', line 69 def document_text ||= {} where = [:where] || 'front document' code = " if count of window is 0\n return null\n else\n return text of (\#{where})\n end\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |
.get_url(options = nil) ⇒ Object
tab (for instance : options = ‘tab 2 of window 1’).
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/osascript/Safari.rb', line 53 def get_url( = nil) ||= {} where = [:where] || 'front document' code = " if count of window is 0\n return null\n else\n return URL of (\#{where})\n end\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |
.open_url(url, options = nil) ⇒ Object
Open URL url in front document or a new window if options[new_window] is true
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/osascript/Safari.rb', line 8 def open_url(url, = nil) ||= {} where = if [:new_window] "(make new tab in window 1)" else "front document" end code = " if count of window is 0\n make new document\n end \n set the URL of \#{where} to \\\"\#{url}\\\"\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |
.run_javascript(code, options = nil) ⇒ Object
Run a javascript code in the front document or the options[:where] tab.
28 29 30 31 32 33 34 35 |
# File 'lib/osascript/Safari.rb', line 28 def run_javascript(code, = nil) ||= {} where = [:where] || 'front document' code = " do Javascript \"\#{code}\" in \#{where}\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |
.window_name(options = nil) ⇒ Object
Returns the name of the front document.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/osascript/Safari.rb', line 38 def window_name( = nil) ||= {} where = [:where] || 'front window' code = " if count of window is 0\n return null\n else\n return name of (\#{where})\n end\n CODE\n Osascript::__asrun(code, 'Safari')\nend\n" |