Sha256: b7321f053315043240dd78272c7210d2aefa416dd7aa38d499d056f371727190

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require 'faraday'
require 'nokogiri'
require 'uri'

module NewspaperWorks
  module Ingest
    class PublicationInfo
      attr_accessor :implementation, :lccn

      def initialize(lccn)
        @lccn = lccn
        @implementation = nil
        load
      end

      def load_chronam_fallback
        @implementation = ChronAmPublicationInfo.new(@lccn)
      end

      def load
        @implementation = LCPublicationInfo.new(@lccn)
        @implementation.load
        # Empty mods is equivalent to 404 for LCCN in LC Catalog:
        load_chronam_fallback if @implementation.empty?
      end

      def respond_to_missing?(symbol, include_priv = false)
        @implementation.respond_to?(symbol, include_priv)
      end

      def method_missing(method, *args, &block)
        # proxy call to underlying implementation:
        if respond_to_missing?(method)
          return @implementation.send(
            method,
            *args,
            &block
          )
        end
        super
      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/publication_info.rb
newspaper_works-1.0.0 lib/newspaper_works/ingest/publication_info.rb
newspaper_works-0.1.0 lib/newspaper_works/ingest/publication_info.rb