lib/marc_cleanup/bib_rubymarc_fixes.rb
def subf_0_fix(record)
    record.fields.each do |field|
      next unless field.class == MARC::DataField && field.tag =~ /^[^9]/ && field['0']
      field_index = record.fields.index(field)
      field.subfields.each do |subfield|
        next unless subfield.code == '0' && subfield.value =~ /^\(uri\)/
        subfield_index = field.subfields.index(subfield)
        record.fields[field_index].subfields[subfield_index].value = subfield.value.gsub(/^\(uri\)(.*)$/, '\1')
      end
    end
    record
  end
### Remove the (uri) prefix from subfield 0s
Remove the (uri) prefix from subfield 0s
Remove the ( uri ) prefix from subfield 0s
def subf_0_fix(record)
    record.fields.each do |field|
      next unless field.class == MARC::DataField && field.tag =~ /^[^9]/ && field['0']
      field_index = record.fields.index(field)
      field.subfields.each do |subfield|
        next unless subfield.code == '0' && subfield.value =~ /^\(uri\)/
        subfield_index = field.subfields.index(subfield)
        record.fields[field_index].subfields[subfield_index].value = subfield.value.gsub(/^\(uri\)(.*)$/, '\1')
      end
    end
    record
  end
def subf_0_fix ( record ) record . fields . each do | field | next unless field . class == MARC :: DataField && field . tag =~ / ^[^9] / && field [ '0' ] field_index = record . fields . index ( field ) field . subfields . each do | subfield | next unless subfield . code == '0' && subfield . value =~ / ^ \( uri \) / subfield_index = field . subfields . index ( subfield ) record . fields [ field_index ] . subfields [ subfield_index ] . value = subfield . value . gsub ( / ^ \( uri \) (.*)$ / , '\1' ) end end record end
Remove the (uri) prefix from subfield 0s
Remove the ( uri ) prefix from subfield 0s
record