Class: PdfSearch::PdfDir
- Inherits:
-
Object
- Object
- PdfSearch::PdfDir
- Defined in:
- lib/pdf_dir.rb
Instance Method Summary collapse
-
#initialize(dir = '.') ⇒ PdfDir
constructor
A new instance of PdfDir.
- #pages ⇒ Object
- #pdf_documents ⇒ Object
- #pdf_file_paths ⇒ Object
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
#pages ⇒ Object
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_documents ⇒ Object
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_paths ⇒ Object
11 12 13 |
# File 'lib/pdf_dir.rb', line 11 def pdf_file_paths Dir.glob(File.join(File.(@dir), '*.pdf')) end |