module Blacklight::Marc::Indexer::Formats
Public Instance Methods
get_format(options = {})
click to toggle source
# File lib/blacklight/marc/indexer/formats.rb, line 155 def get_format(options = {}) lambda do |record, accumulator, context| vals = [] extractor = Traject::MarcExtractor.new('245h', options) extractor.extract(record).select do |v| vals << 'Electronic' if v =~ /electronic\sresource/ end unless vals.empty? vals.uniq! accumulator.concat vals else field007hasC = false extractor = Traject::MarcExtractor.new('007[0-1]', options) extractor.extract(record).each {|v| field007hasC ||= FormatMap.map007(v,vals)} unless vals.empty? vals.uniq! accumulator.concat vals else # check the Leader - this is NOT a repeating field # if we find a matching value there, grab it and return. FormatMap.map_leader(record.leader[6,2],field007hasC,vals,record) unless vals.empty? vals.uniq! accumulator.concat vals else FormatMap.map_leader(record.leader[6],field007hasC,vals,record) if vals.empty? accumulator.concat ['Unknown'] else vals.uniq! accumulator.concat vals end end end end end end