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 fix_microform_007(specific_007)
    return specific_007 unless specific_007.length == 12
    fixed_field = ''
    mat_designation = specific_007[0]
    mat_designation.gsub!(/[^a-hjuz|]/, 'u')
    aspect = specific_007[2]
    aspect.gsub!(/[^abmu|]/, 'u')
    dimensions = specific_007[3]
    dimensions.gsub!(/[^adfghlmopuz|]/, 'u')
    reduction_range = specific_007[4]
    reduction_range.gsub!(/[^a-euv|]/, 'u')
    reduction_ratio = specific_007[5..7]
    unless %w[--- |||].include? reduction_ratio
      reduction_ratio =~ /^[0-9]/ ? reduction_ratio : '---'
      reduction_nums = reduction_ratio.chars.select { |c| c =~ /[0-9]/ }.join('')
      reduction_ratio = reduction_nums.ljust(3, '-')
    end
    color = specific_007[8]
    color.gsub!(/[^bcmuz|]/, 'u')
    emulsion = specific_007[9]
    emulsion.gsub!(/[^abcmnuz|]/, 'u')
    generation = specific_007[10]
    generation.gsub!(/[^abcmu|]/, 'u')
    base = specific_007[11]
    base.gsub!(/[^abcdimnprtuz|]/, 'u')
    fixed_field << mat_designation
    fixed_field << ' '
    fixed_field << aspect
    fixed_field << dimensions
    fixed_field << reduction_range
    fixed_field << reduction_ratio
    fixed_field << color
    fixed_field << emulsion
    fixed_field << generation
    fixed_field << base
    fixed_field
  end
def fix_microform_007 ( specific_007 ) return specific_007 unless specific_007 . length == 12 fixed_field = '' mat_designation = specific_007 [ 0 ] mat_designation . gsub! ( / [^a-hjuz|] / , 'u' ) aspect = specific_007 [ 2 ] aspect . gsub! ( / [^abmu|] / , 'u' ) dimensions = specific_007 [ 3 ] dimensions . gsub! ( / [^adfghlmopuz|] / , 'u' ) reduction_range = specific_007 [ 4 ] reduction_range . gsub! ( / [^a-euv|] / , 'u' ) reduction_ratio = specific_007 [ 5 .. 7 ] unless %w[ --- ||| ] . include? reduction_ratio reduction_ratio =~ / ^[0-9] / ? reduction_ratio : '---' reduction_nums = reduction_ratio . chars . select { | c | c =~ / [0-9] / } . join ( '' ) reduction_ratio = reduction_nums . ljust ( 3 , '-' ) end color = specific_007 [ 8 ] color . gsub! ( / [^bcmuz|] / , 'u' ) emulsion = specific_007 [ 9 ] emulsion . gsub! ( / [^abcmnuz|] / , 'u' ) generation = specific_007 [ 10 ] generation . gsub! ( / [^abcmu|] / , 'u' ) base = specific_007 [ 11 ] base . gsub! ( / [^abcdimnprtuz|] / , 'u' ) fixed_field << mat_designation fixed_field << ' ' fixed_field << aspect fixed_field << dimensions fixed_field << reduction_range fixed_field << reduction_ratio fixed_field << color fixed_field << emulsion fixed_field << generation fixed_field << base fixed_field 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 '
specific_007