Method: Traject::MarcExtractor#collect_subfields
- Defined in:
- lib/traject/marc_extractor.rb
#collect_subfields(field, spec) ⇒ Object
Pass in a marc data field and a Spec object with extraction instructions, returns an ARRAY of one or more strings, subfields extracted and processed per spec. Takes account of options such as :separator
Always returns array, sometimes empty array.
302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/traject/marc_extractor.rb', line 302 def collect_subfields(field, spec) subfields = field.subfields.collect do |subfield| subfield.value if spec.includes_subfield_code?(subfield.code) end.compact return subfields if subfields.empty? # empty array, just return it. if [:separator] && spec.joinable? subfields = [subfields.join([:separator])] end return subfields end |