MARC_set_wrangler.rb
def add_to_record(rec, id_elements, add_to_affix: nil)
    id_elements.each do |ide|
      e = SpecifiedMarcElement.new(ide)
      if rec.tags.include?(e.tag)
        rec.find_all { |field| field.tag == e.tag }.each do |field|
          if field.is_a? MARC::ControlField
            field.value = add_to_value(field.value, "#{@affix}#{add_to_affix}")
          else
            clean_sfs = field.subfields.select { |sf| e.subfields.include?(sf.code) }
            clean_sfs.each do |sf|
              sf.value = add_to_value(sf.value, "#{@affix}#{add_to_affix}")
            end
          end
        end
      end
    end
    rec
  end
# Passing an add_to_affix value allows for custom (e.g. per record or
# subcollection) data to be appended to the global affix. (Note that
# regardlessthe of whether the affix is a prefix or suffix,
# the add_to_affix value, if any, is always appended to the affix.
Passing an add_to_affix value allows for custom  data to be appended to the global affix. (Note that
regardlessthe of whether the affix is a prefix or suffix,
the add_to_affix value, if any, is always appended to the affix.
Passing an add_to_affix value allows for custom data to be appended to the global affix . ( Note that regardlessthe of whether the affix is a prefix or suffix the add_to_affix value if any is always appended to the affix .
def add_to_record(rec, id_elements, add_to_affix: nil)
    id_elements.each do |ide|
      e = SpecifiedMarcElement.new(ide)
      if rec.tags.include?(e.tag)
        rec.find_all { |field| field.tag == e.tag }.each do |field|
          if field.is_a? MARC::ControlField
            field.value = add_to_value(field.value, "#{@affix}#{add_to_affix}")
          else
            clean_sfs = field.subfields.select { |sf| e.subfields.include?(sf.code) }
            clean_sfs.each do |sf|
              sf.value = add_to_value(sf.value, "#{@affix}#{add_to_affix}")
            end
          end
        end
      end
    end
    rec
  end
def add_to_record ( rec , id_elements , add_to_affix : nil ) id_elements . each do | ide | e = SpecifiedMarcElement . new ( ide ) if rec . tags . include? ( e . tag ) rec . find_all { | field | field . tag == e . tag } . each do | field | if field . is_a? MARC :: ControlField field . value = add_to_value ( field . value , "#{@affix}#{add_to_affix}" ) else clean_sfs = field . subfields . select { | sf | e . subfields . include? ( sf . code ) } clean_sfs . each do | sf | sf . value = add_to_value ( sf . value , "#{@affix}#{add_to_affix}" ) end end end end end rec end
Passing an add_to_affix value allows for custom (e.g.
Passing an add_to_affix value allows for custom ( e . g .
rec
id_elements
add_to_affix