Sha256: 6c8cff03e7a60788efdaa8c9dc6d83500f5d1d1b0de2088011b21fbd84795841

Contents?: true

Size: 874 Bytes

Versions: 4

Compression:

Stored size: 874 Bytes

Contents

require 'marc'

module BerkeleyLibrary
  module TIND
    module Mapping
      class Alma
        include Util

        attr_reader :record

        def initialize(xml_file)
          @record = alma_record(xml_file)
        end

        def control_field
          @record.fields.each { |f| return f if f.tag.to_s == '008' }
          nil
        end

        def field_880(subfield6_value)
          @record.fields.each { |f| return f if f.tag.to_s == '880' && f['6'] == subfield6_value }
          nil
        end

        def field(tag)
          @record.fields.each { |f| return f if f.tag.to_s == tag }
          nil
        end

        private

        def alma_record(xml_file)
          file = File.open(xml_file)
          content = file.readlines.map(&:chomp)
          xml = content.join(' ')
          Util.from_xml(xml)
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 lib/berkeley_library/tind/mapping/alma.rb
berkeley_library-tind-0.7.1 lib/berkeley_library/tind/mapping/alma.rb
berkeley_library-tind-0.7.0 lib/berkeley_library/tind/mapping/alma.rb
berkeley_library-tind-0.6.0 lib/berkeley_library/tind/mapping/alma.rb