Sha256: 65bd7e76fb4ceca926207c2d2f007dbeeba94c443044543f7a0b9c8bfda278ad
Contents?: true
Size: 678 Bytes
Versions: 1
Compression:
Stored size: 678 Bytes
Contents
require "pry" module EbooksRenamer class PdfParser class << self 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ebooks_renamer-0.1.4 | lib/ebooks_renamer/pdf_parser.rb |