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
filepath
est 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 = <<~CODE repeat 10 times try set doc to first document whose path is "#{filepath}" return true on error errMsg delay 0.5 end try end repeat return false CODE retour = Osascript::__asrun(code, 'Preview') return retour == 'true' end |
.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(<<~CODE) tell application "Preview" set names to name of every document end tell set text item delimiters to {"', '"} set names to names as text set text item delimiters to {} return "['" & names & "']" CODE # puts "liste = #{liste.inspect}" return liste == "['']" ? [] : eval(liste) end |
.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(<<~CODE) tell application "Preview" set paths to path of every document end tell set text item delimiters to {"', '"} set paths to paths as text set text item delimiters to {} return "['" & paths & "']" CODE # puts "liste = #{liste.inspect}" return liste == "['']" ? [] : eval(liste) end |