Class: PennMARC::Production
- Defined in:
- lib/pennmarc/helpers/production.rb
Overview
Extracts data related to a resource’s production, distribution, manufacture, and publication.
Class Method Summary collapse
-
.distribution_show(record) ⇒ Array<String>
Retrieve distribution values for display from 264 field.
-
.manufacture_show(record) ⇒ Array<String>
Retrieve manufacture values for display from 264 field.
-
.place_of_publication_show(record) ⇒ Object
Retrieve place of publication for display from 752 field and its linked alternate.
- .publication_show(record) ⇒ Object
-
.publication_values(record) ⇒ Array<String>
Retrieve publication values.
-
.show(record) ⇒ Array<String>
Retrieve production values for display from 264 field.
Methods included from Util
#datafield_and_linked_alternate, #join_and_squish, #join_subfields, #linked_alternate, #linked_alternate_not_6_or_8, #prefixed_subject_and_alternate, #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_trailing, #valid_subject_genre_source_code?
Class Method Details
.distribution_show(record) ⇒ Array<String>
Retrieve distribution values for display from 264 field.
17 18 19 |
# File 'lib/pennmarc/helpers/production.rb', line 17 def distribution_show(record) get_264_or_880_fields(record, '2') end |
.manufacture_show(record) ⇒ Array<String>
Retrieve manufacture values for display from 264 field.
24 25 26 |
# File 'lib/pennmarc/helpers/production.rb', line 24 def manufacture_show(record) get_264_or_880_fields(record, '3') end |
.place_of_publication_show(record) ⇒ Object
legacy version returns array of hash objects including data for display link
Retrieve place of publication for display from 752 field and its linked alternate.
97 98 99 100 101 102 103 104 105 |
# File 'lib/pennmarc/helpers/production.rb', line 97 def place_of_publication_show(record) record.fields(%w[752 880]).filter_map do |field| next if field.tag == '880' && subfield_values(field, '6').exclude?('752') place = join_subfields(field, &subfield_not_in?(%w[6 8 e w])) place_extra = join_subfields(field, &subfield_in?(%w[e w])) "#{place} #{place_extra}" end end |
.publication_show(record) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pennmarc/helpers/production.rb', line 72 def publication_show(record) values = record.fields('245').first(1).flat_map { |field| subfield_values(field, 'f') } values += record.fields(%w[260 261 262]).first(1).map do |field| join_subfields(field, &subfield_not_in?(%w[6 8])) end values += record.fields('880').filter_map { |field| field if subfield_value?(field, '6', /^(260|261|262)/) } .first(1).map { |field| join_subfields(field, &subfield_not_in?(%w[6 8])) } values += record.fields('880').filter_map do |field| next unless subfield_value?(field, '6', /^245/) join_subfields(field, &subfield_in?(['f'])) end values += get_264_or_880_fields(record, '1') values.compact_blank end |
.publication_values(record) ⇒ Array<String>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pennmarc/helpers/production.rb', line 33 def publication_values(record) # first get inclusive dates values = record.fields('245').first(1).flat_map { |field| subfield_values(field, 'f') } added_2xx = record.fields(%w[260 261 262]) .first(1) .map do |field| join_subfields(field, &subfield_not_in?(['6'])).squish end if added_2xx.present? values += added_2xx else fields264 = record.fields('264') pub_place_name = fields264 .find(-> { [] }) { |field| field.indicator2 == '1' } .filter_map { |sf| sf.value if sf.code.in?(%w[a b]) } pub_date = fields264 .find(-> { [] }) { |field| field.indicator2 == '1' } .filter_map { |sf| sf.value if sf.code.in?(['c']) } copyright_date = fields264 .find(-> { [] }) { |field| field.indicator2 == '4' } .filter_map { |sf| "#{pub_date.present? ? ', ' : ''}#{sf.value}" if sf.code.in?(['c']) } joined264 = Array.wrap((pub_place_name + pub_date + copyright_date).join(' ')) values += joined264 end values.filter_map { |value| value&.strip } end |
.show(record) ⇒ Array<String>
Retrieve production values for display from 264 field.
10 11 12 |
# File 'lib/pennmarc/helpers/production.rb', line 10 def show(record) get_264_or_880_fields(record, '0') end |