class Traject::UMichFormat::BibFormat

given a record, find the bib_format code

Attributes

code[R]

Public Class Methods

new(record) click to toggle source

Determine the bib format code

@param [MARC::Record] record The record to test

# File lib/traject/umich_format/bib_format.rb, line 10
def initialize(record)
  ldr = record.leader

  type = ldr[6]
  lev  = ldr[7]
  @code = self.determine_bib_code(type, lev)
end

Public Instance Methods

bibformat_bk(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 35
def bibformat_bk(type, lev)
  %w[a t].include?(type) && %w[a c d m].include?(lev)
end
bibformat_cf(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 39
def bibformat_cf(type, lev)
  (type == 'm') && %w[a b c d i m s].include?(lev)
end
bibformat_mp(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 51
def bibformat_mp(type, lev)
  %w[e f].include?(type) && %w[a b c d i m s].include?(lev)
end
bibformat_mu(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 47
def bibformat_mu(type, lev)
  %w[c d i j].include?(type) && %w[a b c d i m s].include?(lev)
end
bibformat_mx(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 59
def bibformat_mx(type, lev)
  %w[b p].include?(type) && %w[a b c d i m s].include?(lev)
end
bibformat_se(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 55
def bibformat_se(type, lev)
  (type == 'a') && %w[b s i].include?(lev)
end
bibformat_vm(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 43
def bibformat_vm(type, lev)
  %w[g k o r].include?(type) && %w[a b c d i m s].include?(lev)
end
determine_bib_code(type, lev) click to toggle source
# File lib/traject/umich_format/bib_format.rb, line 18
def determine_bib_code(type, lev)
  return 'BK' if bibformat_bk(type, lev)
  return "CF" if bibformat_cf(type, lev)
  return "VM" if bibformat_vm(type, lev)
  return "MU" if bibformat_mu(type, lev)
  return "MP" if bibformat_mp(type, lev)
  return "SE" if bibformat_se(type, lev)
  return "MX" if bibformat_mx(type, lev)

  # Extra check for serial
  return "SE" if lev == 's'

  # No match
  return 'XX'

end