lib/marc_cleanup/bib_rubymarc_fixes.rb
### Replace tab and newline characters with a space
Replace tab and newline characters with a space
Replace tab and newline characters with a space
def tab_newline_fix(record)
    regex = /[\x09\n\r]/
    record.leader.gsub!(regex, ' ')
    record.fields.each do |field|
      field_index = record.fields.index(field)
      if field.class == MARC::DataField
        curr_subfield = 0
        final_subfield = field.subfields.length
        field.indicator1.gsub!(regex, ' ') if field.indicator1
        field.indicator2.gsub!(regex, ' ') if field.indicator2
        while curr_subfield < final_subfield
          record.fields[field_index].subfields[curr_subfield].value.gsub!(regex, ' ')
          curr_subfield += 1
        end
      else
        record.fields[field_index].value.gsub!(regex, ' ')
      end
    end
    record
  end
def tab_newline_fix ( record ) regex = / [ \x09 \n \r ] / record . leader . gsub! ( regex , ' ' ) record . fields . each do | field | field_index = record . fields . index ( field ) if field . class == MARC :: DataField curr_subfield = 0 final_subfield = field . subfields . length field . indicator1 . gsub! ( regex , ' ' ) if field . indicator1 field . indicator2 . gsub! ( regex , ' ' ) if field . indicator2 while curr_subfield < final_subfield record . fields [ field_index ] . subfields [ curr_subfield ] . value . gsub! ( regex , ' ' ) curr_subfield += 1 end else record . fields [ field_index ] . value . gsub! ( regex , ' ' ) end end record end
Replace tab and newline characters with a space
Replace tab and newline characters with a space
record