lib/marc_cleanup/bib_rubymarc_fixes.rb
def field_delete(tags, record, indicators = {})
    if indicators.empty?
      record.fields.delete_if { |field| tags.include? field.tag }
    else
      ind_1 = indicators[:ind_1]
      ind_2 = indicators[:ind_2]
      if ind_1 && ind_2
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_1.include? field.indicator1) && (ind_2.include? field.indicator2) }
      elsif ind_1
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_1.include? field.indicator1) }
      else
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_2.include? field.indicator2) }
      end
    end
    record
  end
## Can delete fields based on tags alone, or with
## optional indicator values provided in arrays
Can delete fields based on tags alone, or with
optional indicator values provided in arrays
Can delete fields based on tags alone or with optional indicator values provided in arrays
def field_delete(tags, record, indicators = {})
    if indicators.empty?
      record.fields.delete_if { |field| tags.include? field.tag }
    else
      ind_1 = indicators[:ind_1]
      ind_2 = indicators[:ind_2]
      if ind_1 && ind_2
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_1.include? field.indicator1) && (ind_2.include? field.indicator2) }
      elsif ind_1
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_1.include? field.indicator1) }
      else
        record.fields.delete_if { |field| (tags.include? field.tag) && (ind_2.include? field.indicator2) }
      end
    end
    record
  end
def field_delete ( tags , record , indicators = { } ) if indicators . empty? record . fields . delete_if { | field | tags . include? field . tag } else ind_1 = indicators [ :ind_1 ] ind_2 = indicators [ :ind_2 ] if ind_1 && ind_2 record . fields . delete_if { | field | ( tags . include? field . tag ) && ( ind_1 . include? field . indicator1 ) && ( ind_2 . include? field . indicator2 ) } elsif ind_1 record . fields . delete_if { | field | ( tags . include? field . tag ) && ( ind_1 . include? field . indicator1 ) } else record . fields . delete_if { | field | ( tags . include? field . tag ) && ( ind_2 . include? field . indicator2 ) } end end record end
Can delete fields based on tags alone, or with
optional indicator values provided in arrays
Can delete fields based on tags alone or with optional indicator values provided in arrays
tags
record
indicators