Class: PennMARC::Relation
- Defined in:
- lib/pennmarc/helpers/relation.rb
Overview
These MARC parsing method are grouped in virtue of their role as describing the relationship of a record to other records.
Constant Summary collapse
- CHRONOLOGY_PREFIX =
'CHR'
- RELATED_WORK_FIELDS =
%w[700 710 711 730].freeze
- CONTAINS_FIELDS =
%w[700 710 711 730 740].freeze
Constants included from Util
Util::TRAILING_PUNCTUATIONS_PATTERNS
Class Method Summary collapse
-
.chronology_show(record) ⇒ Array
Get “chronology” information from specially-prefixed 650 (subject) fields.
-
.constituent_unit_show(record) ⇒ Array
Get “Constituent Unit” values from MARC 774.
-
.contained_in_show(record) ⇒ Array<String>
Get values for “Host Item” for this record.
-
.contains_show(record, relator_map: Mappers.relator) ⇒ Array<String>
Get “Contains” values from CONTAINS_FIELDS in the 7XX range.
-
.has_supplement_show(record) ⇒ Array
Get “Has Supplement” values from MARC 770.
-
.publications_about_show(record) ⇒ Array
Get notes for “Publication About” from MARC 581.
-
.related_collections_show(record) ⇒ Array
Get notes for Related Collections from MARC 544.
-
.related_work_show(record, relator_map: Mappers.relator) ⇒ Array
Get related work from RELATED_WORK_FIELDS in the 7XX range.
Methods included from Util
#append_relator, #append_trailing, #datafield_and_linked_alternate, #field_defined?, #field_or_its_linked_alternate?, #join_and_squish, #join_subfields, #linked_alternate, #linked_alternate_not_6_or_8, #no_subfield_value_matches?, #prefixed_subject_and_alternate, #relator, #relator_join_separator, #relator_term_subfield, #remove_paren_value_from_subfield_i, #subfield_defined?, #subfield_in?, #subfield_not_in?, #subfield_undefined?, #subfield_value?, #subfield_value_in?, #subfield_value_not_in?, #subfield_values, #subfield_values_for, #substring_after, #substring_before, #translate_relator, #trim_punctuation, #trim_trailing, #trim_trailing!, #valid_subject_genre_source_code?
Class Method Details
.chronology_show(record) ⇒ Array
why do we stuff chronology data in a 650 field?
Get “chronology” information from specially-prefixed 650 (subject) fields
28 29 30 |
# File 'lib/pennmarc/helpers/relation.rb', line 28 def chronology_show(record) prefixed_subject_and_alternate(record, CHRONOLOGY_PREFIX) end |
.constituent_unit_show(record) ⇒ Array
Get “Constituent Unit” values from MARC 774. Include subfield values in i, a, s and t.
98 99 100 101 102 103 104 |
# File 'lib/pennmarc/helpers/relation.rb', line 98 def constituent_unit_show(record) values = record.fields('774').filter_map do |field| join_subfields(field, &subfield_in?(%w[i a s t])) end constituent_values = values + linked_alternate(record, '774', &subfield_in?(%w[i a s t])) constituent_values.uniq end |
.contained_in_show(record) ⇒ Array<String>
Get values for “Host Item” for this record. Values contained in this field should be sufficient to locate host item record.
18 19 20 21 22 |
# File 'lib/pennmarc/helpers/relation.rb', line 18 def contained_in_show(record) record.fields('773').map { |field| join_subfields(field, &subfield_not_in?(%w[6 7 8 w])) }.uniq end |
.contains_show(record, relator_map: Mappers.relator) ⇒ Array<String>
is it okay to include 880 $4 here? Legacy includes untranslated $4, why?
Get “Contains” values from CONTAINS_FIELDS in the 7XX range. Must have indicator 2 value of 2 indicating an “Analytical Entry” meaning that the record is contained by the matching field. Map relator codes in sf 4. Ignore values in sf 0, 5, 6, and 8.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pennmarc/helpers/relation.rb', line 77 def contains_show(record, relator_map: Mappers.relator) fields = record.fields(CONTAINS_FIELDS) fields += record.fields('880').select { |f| subfield_value?(f, '6', /^(#{CONTAINS_FIELDS.join('|')})/) } fields.filter_map { |field| next unless field.indicator2 == '2' relator_term_sf = relator_term_subfield(field) sf_exclude = %w[0 4 5 6 8 i] << relator_term_sf values_with_title_prefix(field, relator_term_sf: relator_term_sf, relator_map: relator_map, &subfield_not_in?(sf_exclude)) }.uniq end |
.has_supplement_show(record) ⇒ Array
Get “Has Supplement” values from MARC 770. Ignore subfield values in 6 and 8.
110 111 112 |
# File 'lib/pennmarc/helpers/relation.rb', line 110 def has_supplement_show(record) datafield_and_linked_alternate(record, '770') end |
.publications_about_show(record) ⇒ Array
Get notes for “Publication About” from MARC 581.
42 43 44 |
# File 'lib/pennmarc/helpers/relation.rb', line 42 def publications_about_show(record) datafield_and_linked_alternate(record, '581') end |
.related_collections_show(record) ⇒ Array
Get notes for Related Collections from MARC 544.
35 36 37 |
# File 'lib/pennmarc/helpers/relation.rb', line 35 def (record) datafield_and_linked_alternate(record, '544') end |
.related_work_show(record, relator_map: Mappers.relator) ⇒ Array
Get related work from RELATED_WORK_FIELDS in the 7XX range. Require presence of sf t (title) and absence of an indicator2 value. Prefix returned values with sf i value. Also map relator codes found in sf 4. Ignore sf 0.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pennmarc/helpers/relation.rb', line 51 def (record, relator_map: Mappers.relator) fields = record.fields(RELATED_WORK_FIELDS) fields += record.fields('880').select { |f| subfield_value?(f, '6', /^(#{RELATED_WORK_FIELDS.join('|')})/) } fields.filter_map { |field| next if field.indicator2.present? next unless subfield_defined?(field, 't') relator_term_sf = relator_term_subfield(field) sf_exclude = %w[0 4 6 8 i] << relator_term_sf values_with_title_prefix(field, relator_term_sf: relator_term_sf, relator_map: relator_map, &subfield_not_in?(sf_exclude)) }.uniq end |