Class: EbooksRenamer::PdfParser
- Defined in:
- lib/ebooks_renamer/pdf_parser.rb
Class Method Summary collapse
Class Method Details
.parse(filename) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ebooks_renamer/pdf_parser.rb', line 5 def parse(filename) File.open(filename, 'rb') do |io| reader = PDF::Reader.new(io) if reader && reader.info && reader.info[:Title].present? OpenStruct.new title: reader.info[:Title], author: reader.info[:Author], pages: reader.page_count end end rescue Exception => e # Note: we skip the file that we can't process # and allow the process to continue puts "Skip file '#{filename}'" puts "Due to the unexpected error: #{e.}" end |