lib/marc_cleanup/bib_rubymarc_fixes.rb
### Replaces obsolete values with the current value;
#     if encoding level, cataloging form or multipart indicators
#     are outside accepted values, replace them with 'unknown'
#     normalize the indicator length and subfield code length to 2;
#     make the last 4 positions the only possible value of '4500'
Replaces obsolete values with the current value;
if encoding level, cataloging form or multipart indicators
are outside accepted values, replace them with 'unknown'
normalize the indicator length and subfield code length to 2;
make the last 4 positions the only possible value of '4500'
Replaces obsolete values with the current value ; if encoding level cataloging form or multipart indicators are outside accepted values replace them with ' unknown ' normalize the indicator length and subfield code length to 2 ; make the last 4 positions the only possible value of ' 4500 '
def leaderfix(record)
    correct_leader = /[0-9]{5}[acdnp][ac-gijkmoprt][a-dims][\sa][\sa]22[0-9]{5}[1-8uzI-M\s][aciu\s][abcr\s]4500/
    leader = record.leader
    return record if leader =~ correct_leader
    length = leader[0, 5]
    status = leader[5]
    status.gsub!(/[^acdnp]/, 'n')
    record_type = leader[6]
    bib_level = leader[7]
    control = leader[8]
    control.gsub!(/[^a ]/, ' ')
    character_scheme = leader[9]
    indsub = '22'
    base_addr = leader[12, 5]
    enc_level = leader[17]
    enc_level.gsub!(/[^1-8uzIJKLM ]/, 'u')
    cat_form = leader[18]
    cat_form.gsub!(/[^aciu\s]/, 'u')
    multipart = leader[19]
    multipart.gsub!(/[^abcr ]/, ' ')
    final4 = '4500'
    fixed_leader = [length, status, record_type, bib_level, control, character_scheme, indsub, base_addr, enc_level, cat_form, multipart, final4].join
    record.leader = fixed_leader
    record
  end
def leaderfix ( record ) correct_leader = / [0-9]{5}[acdnp][ac-gijkmoprt][a-dims][ \s a][ \s a]22[0-9]{5}[1-8uzI-M \s ][aciu \s ][abcr \s ]4500 / leader = record . leader return record if leader =~ correct_leader length = leader [ 0 , 5 ] status = leader [ 5 ] status . gsub! ( / [^acdnp] / , 'n' ) record_type = leader [ 6 ] bib_level = leader [ 7 ] control = leader [ 8 ] control . gsub! ( / [^a ] / , ' ' ) character_scheme = leader [ 9 ] indsub = '22' base_addr = leader [ 12 , 5 ] enc_level = leader [ 17 ] enc_level . gsub! ( / [^1-8uzIJKLM ] / , 'u' ) cat_form = leader [ 18 ] cat_form . gsub! ( / [^aciu \s ] / , 'u' ) multipart = leader [ 19 ] multipart . gsub! ( / [^abcr ] / , ' ' ) final4 = '4500' fixed_leader = [ length , status , record_type , bib_level , control , character_scheme , indsub , base_addr , enc_level , cat_form , multipart , final4 ] . join record . leader = fixed_leader record end
Replaces obsolete values with the current value;
if encoding level, cataloging form or multipart indicators
are outside accepted values, replace them with 'unknown'
normalize the indicator length and subfield code length to 2;
make the last 4 positions the only possible value of '4500'
Replaces obsolete values with the current value ; if encoding level cataloging form or multipart indicators are outside accepted values replace them with ' unknown ' normalize the indicator length and subfield code length to 2 ; make the last 4 positions the only possible value of ' 4500 '
record