Module: BookType
- Includes:
- RecordType
- Defined in:
- lib/enhanced_marc/book_type.rb
Overview
Methods for Book records
Instance Method Summary collapse
- #biography?(human_readable = false) ⇒ Boolean (also: #is_biography?)
- #festschrift? ⇒ Boolean (also: #is_festchrift?)
-
#illustrated?(human_readable = false) ⇒ Boolean
(also: #is_illustrated?)
TODO: simplify this method.
- #literary_form(human_readable = false) ⇒ Object
-
#manuscript? ⇒ Boolean
(also: #is_manuscript?)
Checks the leader and any 006 fields to determine if the record is a manuscript.
- #set_manuscript(value = false, field = nil) ⇒ Object
Instance Method Details
#biography?(human_readable = false) ⇒ Boolean Also known as: is_biography?
40 41 42 43 44 45 46 47 48 |
# File 'lib/enhanced_marc/book_type.rb', line 40 def biography?(human_readable = false) biog_map = { 'a' => 'Autobiography', 'b' => 'Individual biography', 'c' => 'Collective biography', 'd' => 'Contains biographical information' } human_readable = biog_map if human_readable field_parser({ match: 'BKS', start: 34, end: 1}, { match: /[at]{1}/, start: 17, end: 1}, human_readable) end |
#festschrift? ⇒ Boolean Also known as: is_festchrift?
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/enhanced_marc/book_type.rb', line 52 def festschrift? return true if self['008'].value[30, 1] == '1' && @record_type == 'BKS' @fields.each_by_tag('006') do |fxd_fld| if fxd_fld.value[0, 1].match(/[at]{1}/) && fxd_fld.value[13, 1] == '1' next end return true end false end |
#illustrated?(human_readable = false) ⇒ Boolean Also known as: is_illustrated?
TODO: simplify this method
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/enhanced_marc/book_type.rb', line 66 def illustrated?(human_readable = false) ills_map = { 'a' => 'Illustrations', 'b' => 'Maps', 'c' => 'Portraits', 'd' => 'Charts', 'e' => 'Plans', 'f' => 'Plates', 'g' => 'Music', 'h' => 'Facsimilies', 'i' => 'Coats of arms', 'j' => 'Genealogical tables', 'k' => 'Forms', 'l' => 'Samples', 'm' => 'Phonodisc', 'o' => 'Photographs', 'p' => 'Illuminations' } contents = [] if record_type == 'BKS' self['008'].value[18, 4].split(//).each do |char| next if char == ' ' if human_readable contents << ills_map[char] if ills_map[char] else contents << char end end end @fields.each_by_tag('006') do |fxd_fld| next unless fxd_fld.value[0, 1] =~ /[at]{1}/ fxd_fld.value[1, 4].split(//).each do |char| next if char == ' ' if human_readable contents << ills_map[char] if ills_map[char] else contents << char end end end return false if contents.empty? contents end |
#literary_form(human_readable = false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/enhanced_marc/book_type.rb', line 28 def literary_form(human_readable = false) lit_map = { '0' => 'Non-fiction', '1' => 'Fiction', 'c' => 'Comic', 'd' => 'Drama', 'e' => 'Essay', 'f' => 'Novel', 'h' => 'Humor/satire', 'i' => 'Letter', 'j' => 'Short story', 'm' => 'Mixed', 'p' => 'Poetry', 's' => 'Speech', 'u' => 'Unknown' } human_readable = lit_map if human_readable field_parser({ match: 'BKS', start: 33, end: 1 }, { match: /[at]{1}/, start: 16, end: 1 }, human_readable) end |
#manuscript? ⇒ Boolean Also known as: is_manuscript?
Checks the leader and any 006 fields to determine if the record is a manuscript. Returns a boolean.
9 10 11 12 13 14 15 |
# File 'lib/enhanced_marc/book_type.rb', line 9 def manuscript? return true if @leader[6,1] == 't' @fields.each_by_tag('006') do |fxd_fld| return true if fxd_fld.value[0, 1] == 't' end false end |
#set_manuscript(value = false, field = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/enhanced_marc/book_type.rb', line 19 def set_manuscript(value = false, field = nil) if field return Exception.new('Field is not an 006') unless field.tag == '006' field.value[0] = value ? 't' : 'a' else @leader[6] = value ? 't' : 'a' end end |