Class: Traject::UMichFormat::BibFormat
- Inherits:
-
Object
- Object
- Traject::UMichFormat::BibFormat
- Defined in:
- lib/traject/umich_format/bib_format.rb
Overview
given a record, find the bib_format code
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #bibformat_bk(type, lev) ⇒ Object
- #bibformat_cf(type, lev) ⇒ Object
- #bibformat_mp(type, lev) ⇒ Object
- #bibformat_mu(type, lev) ⇒ Object
- #bibformat_mx(type, lev) ⇒ Object
- #bibformat_se(type, lev) ⇒ Object
- #bibformat_vm(type, lev) ⇒ Object
- #determine_bib_code(type, lev) ⇒ Object
-
#initialize(record) ⇒ BibFormat
constructor
Determine the bib format code.
Constructor Details
#initialize(record) ⇒ BibFormat
Determine the bib format code
10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/traject/umich_format/bib_format.rb', line 4 def code @code end |
Instance Method Details
#bibformat_bk(type, lev) ⇒ Object
35 36 37 |
# 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) ⇒ Object
39 40 41 |
# 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) ⇒ Object
51 52 53 |
# 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) ⇒ Object
47 48 49 |
# 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) ⇒ Object
59 60 61 |
# 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) ⇒ Object
55 56 57 |
# 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) ⇒ Object
43 44 45 |
# 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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |