Method: Traject::MarcExtractor#specs_covering_field

Defined in:
lib/traject/marc_extractor.rb

#specs_covering_field(field) ⇒ Object

Find Spec objects, if any, covering extraction from this field. Returns an array of 0 or more MarcExtractor::Spec objects

When given an 880, will return the spec (if any) for the linked tag iff we have a $6 and we want the alternate script.

Returns an empty array in case of no matching extraction specs.



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/traject/marc_extractor.rb', line 325

def specs_covering_field(field)
  tag = field.tag

  # Short-circuit the unintersting stuff
  return [] unless interesting_tag?(tag)

  # Due to bug in jruby https://github.com/jruby/jruby/issues/886 , we need
  # to do this weird encode gymnastics, which fixes it for mysterious reasons.

  if tag == "880" && field['6']
    tag = field["6"].encode(field["6"].encoding).byteslice(0,3)
  end

  # Take the resulting tag and get the spec from it (or the default nil if there isn't a spec for this tag)
  spec = self.spec_hash[tag] || []
end