Sha256: d3f822bc9ac3949ce98951bc61ee86c3d435943f82638b98b992c9e2e48e2f64

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module NewspaperWorks
  module Ingest
    module NDNP
      class PageIngest
        include NewspaperWorks::Ingest::NDNP::NDNPMetsHelper

        attr_accessor :path, :dmdid, :doc, :files

        def initialize(path = nil, dmdid = nil, parent = nil)
          raise ArgumentError, 'No path provided' if path.nil?
          @path = path
          @dmdid = dmdid
          @doc = nil
          @parent = parent
          @metadata = nil
          load_doc
          @files = page_files.values.map(&method(:normalize_path))
        end

        def inspect
          format(
            "<#{self.class}:0x000000000%<oid>x\n" \
              "\tpath: '#{path}',\n" \
              "\tdmdid: '#{dmdid}' ...>",
            oid: object_id << 1
          )
        end

        def metadata
          return @metadata unless @metadata.nil?
          @metadata = NewspaperWorks::Ingest::NDNP::PageMetadata.new(
            path,
            self,
            dmdid
          )
        end

        private

          def load_doc
            @doc = @parent.doc unless @parent.nil?
            @doc = Nokogiri::XML(File.open(path)) if @doc.nil?
          end
      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/ndnp/page_ingest.rb
newspaper_works-1.0.0 lib/newspaper_works/ingest/ndnp/page_ingest.rb
newspaper_works-0.1.0 lib/newspaper_works/ingest/ndnp/page_ingest.rb