Class: PdfSearch::PdfDir

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_dir.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir = '.') ⇒ PdfDir

Returns a new instance of PdfDir.



7
8
9
# File 'lib/pdf_dir.rb', line 7

def initialize(dir = '.')
	@dir = dir
end

Instance Method Details

#pagesObject



23
24
25
26
27
28
29
30
31
# File 'lib/pdf_dir.rb', line 23

def pages
	Enumerator.new do |e|
		pdf_documents.each do |pdf_reader|
			pdf_reader.pages.each do |page|
				e << [page, pdf_reader, Digest::SHA256.hexdigest(Marshal.dump(pdf_reader.info))]
			end
		end
	end
end

#pdf_documentsObject



15
16
17
18
19
20
21
# File 'lib/pdf_dir.rb', line 15

def pdf_documents
	Enumerator.new do |e|
			pdf_file_paths.each do |pdf_file_path|
				e << PDF::Reader.new(pdf_file_path)
			end
	end
end

#pdf_file_pathsObject



11
12
13
# File 'lib/pdf_dir.rb', line 11

def pdf_file_paths
	Dir.glob(File.join(File.expand_path(@dir), '*.pdf'))
end