Class: Osascript::Preview
- Inherits:
-
Object
- Object
- Osascript::Preview
- Defined in:
- lib/osascript/Preview.rb
Class Method Summary collapse
-
.document_opened?(filepath) ⇒ Boolean
True si le document de path
filepathest ouvert. -
.documents_names ⇒ Array
preview.
- .documents_paths ⇒ Object
-
.open_document(filepath) ⇒ Object
Ouvre le document
filepath.
Class Method Details
.document_opened?(filepath) ⇒ Boolean
Returns true si le document de path filepath est ouvert.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/osascript/Preview.rb', line 16 def document_opened?(filepath) code = " repeat 10 times\n try\n set doc to first document whose path is \"\#{filepath}\"\n return true\n on error errMsg\n delay 0.5\n end try\n end repeat\n return false\n CODE\n retour = Osascript::__asrun(code, 'Preview')\n return retour == 'true'\nend\n" |
.documents_names ⇒ Array
preview
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/osascript/Preview.rb', line 34 def documents_names liste = Osascript::__asrun(" tell application \"Preview\"\n set names to name of every document\n end tell\n set text item delimiters to {\"', '\"}\n set names to names as text\n set text item delimiters to {}\n return \"['\" & names & \"']\"\n CODE\n # puts \"liste = \#{liste.inspect}\"\n return liste == \"['']\" ? [] : eval(liste)\nend\n") |
.documents_paths ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/osascript/Preview.rb', line 48 def documents_paths liste = Osascript::__asrun(" tell application \"Preview\"\n set paths to path of every document\n end tell\n set text item delimiters to {\"', '\"}\n set paths to paths as text\n set text item delimiters to {}\n return \"['\" & paths & \"']\"\n CODE\n # puts \"liste = \#{liste.inspect}\"\n return liste == \"['']\" ? [] : eval(liste)\nend\n") |
.open_document(filepath) ⇒ Object
Ouvre le document filepath
11 12 13 |
# File 'lib/osascript/Preview.rb', line 11 def open_document(filepath) Osascript::__asrun("open POSIX file \"#{filepath}\"", 'Preview') end |