Sha256: a546c9ca756d74d8869ca4dd70016be62f9c82077ca2ec8ec159a20da1ea90e6

Contents?: true

Size: 830 Bytes

Versions: 3

Compression:

Stored size: 830 Bytes

Contents

require 'find'

module NewspaperWorks
  module Ingest
    class PDFIssues
      include Enumerable
      include NewspaperWorks::Ingest::PathEnumeration

      attr_accessor :path, :publication, :pdf_paths

      alias paths pdf_paths

      def initialize(path, publication)
        @path = path
        # as a NewspaperWorks::Ingest::PublicationInfo object:
        @publication = publication
        @pdf_paths = valid_pdfs(path)
      end

      def valid_pdfs(path)
        target = []
        Find.find(path) do |p|
          next if File.directory?(p)
          next unless p.end_with?('.pdf')
          target.push(p)
        end
        target
      end

      def lccn
        @publication.lccn
      end

      def info(path)
        NewspaperWorks::Ingest::PDFIssue.new(path, @publication)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 lib/newspaper_works/ingest/pdf_issues.rb
newspaper_works-1.0.0 lib/newspaper_works/ingest/pdf_issues.rb
newspaper_works-0.1.0 lib/newspaper_works/ingest/pdf_issues.rb