blob: d8cbf9e05239520966b76da8226e71f0f014f338 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
module PDFview
@files = Hash.new
def PDFview.open(*list)
begin
[*list].flatten.each do |file|
filename = fullname(file)
if FileTest.file?(filename) then
result = `pdfopen --file #{filename} 2>&1`
@files[filename] = true
end
end
rescue
end
end
def PDFview.close(*list)
[*list].flatten.each do |file|
filename = fullname(file)
begin
if @files.key?(filename) then
result = `pdfclose --file #{filename} 2>&1`
else
closeall
return
end
rescue
end
@files.delete(filename)
end
end
def PDFview.closeall
begin
result = `pdfclose --all 2>&1`
rescue
end
@files.clear
end
def PDFview.fullname(name)
name + if name =~ /\.pdf$/ then '' else '.pdf' end
end
end
# PDFview.open("t:/document/show-exa.pdf")
# PDFview.open("t:/document/show-gra.pdf")
# PDFview.close("t:/document/show-exa.pdf")
# PDFview.close("t:/document/show-gra.pdf")
|