Sha256: 09f913e5dddc8fae49ea03b63cd41c8256c96955e2cb44666581b74e235620b1
Contents?: true
Size: 698 Bytes
Versions: 2
Compression:
Stored size: 698 Bytes
Contents
module EbooksRenamer class PdfParser class << self using AgileUtils::BlankExt 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 => 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.message}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ebooks_renamer-0.2.1 | lib/ebooks_renamer/pdf_parser.rb |
ebooks_renamer-0.2.0 | lib/ebooks_renamer/pdf_parser.rb |