Class: PennMARC::Series

Inherits:
Helper
  • Object
show all
Defined in:
lib/pennmarc/helpers/series.rb

Overview

Do Series and series-related field processing. Many of these fields are added entries that are justified by corresponding series statements (usually 490). These fields provide information about the published series in which a book, encoded finding aid, or other published work has appeared

Constant Summary collapse

DISPLAY_TAGS =

800 - Series Added Entry-Personal Name - www.loc.gov/marc/bibliographic/bd800.html 810 - Series Added Entry-Corporate Name - www.loc.gov/marc/bibliographic/bd810.html 410 - Series Statement/Added Entry-Corporate Name - www.loc.gov/marc/bibliographic/bd410.html 811 - Series Added Entry-Meeting Name - www.loc.gov/marc/bibliographic/bd811.html 830 - Series Added Entry-Uniform Title - www.loc.gov/marc/bibliographic/bd830.html 400 - Series Statement/Added Entry-Personal Name - www.loc.gov/marc/bibliographic/bd400.html 411 - Series Statement/Added Entry Meeting Name - www.loc.gov/marc/bibliographic/bd411.html 440 - Series Statement/Added Entry-Title - www.loc.gov/marc/bibliographic/bd440.html 490 - Series Statement - www.loc.gov/marc/bibliographic/bd490.html

%w[800 810 811 830 400 410 411 440 490].freeze

Constants included from Util

Util::TRAILING_PUNCTUATIONS_PATTERNS

Class Method Summary collapse

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

.get_continued_by_show(record) ⇒ Array<String>

Information concerning the immediate successor to the target item (chronological relationship). When a note is generated from this field, the introductory phrase may be generated based on the value in the second indicator position for display. www.loc.gov/marc/bibliographic/bd785.html

Parameters:

  • record (MARC::Record)

Returns:

  • (Array<String>)

    continued by fields string



115
116
117
# File 'lib/pennmarc/helpers/series.rb', line 115

def get_continued_by_show(record)
  continues(record, '785').uniq
end

.get_continues_show(record) ⇒ Array<String>

Information concerning the immediate predecessor of the target item (chronological relationship). When a note is generated from this field, the introductory term or phrase may be generated based on the value in the second indicator position for display. www.loc.gov/marc/bibliographic/bd780.html

Parameters:

  • record (MARC::Record)

Returns:

  • (Array<String>)

    continues fields string



105
106
107
# File 'lib/pennmarc/helpers/series.rb', line 105

def get_continues_show(record)
  continues(record, '780').uniq
end

.search(record) ⇒ Array<String>

Series fields for search.

Parameters:

  • record (MARC::Record)

Returns:

  • (Array<String>)

    array of series values



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
# File 'lib/pennmarc/helpers/series.rb', line 70

def search(record)
  values = record.fields(%w[400 410 411]).filter_map do |field|
    subfields = if field.indicator2 != '0'
                  %w[4 6 8]
                elsif field.indicator2 != '1'
                  %w[4 6 8 a]
                else
                  next
                end
    join_subfields(field, &subfield_not_in?(subfields))
  end
  values += record.fields(%w[440]).filter_map do |field|
    join_subfields(field, &subfield_not_in?(%w[0 5 6 8 w]))
  end
  values += record.fields(%w[800 810 811]).filter_map do |field|
    join_subfields(field, &subfield_not_in?(%w[0 4 5 6 7 8 w]))
  end
  values += record.fields(%w[830]).filter_map do |field|
    join_subfields(field, &subfield_not_in?(%w[0 5 6 7 8 w]))
  end
  values += record.fields(%w[533]).filter_map do |field|
    filtered_values = field.filter_map { |sf| sf.value if sf.code == 'f' }
    next if filtered_values.empty?

    filtered_values.map { |v| v.gsub(/\(|\)/, '') }.join(' ')
  end
  values.uniq
end

.show(record, relator_map: Mappers.relator) ⇒ Array<String>

Fields for display that pertain to series information.

Parameters:

  • record (MARC::Record)
  • relator_map (Hash) (defaults to: Mappers.relator)

Returns:

  • (Array<String>)

    array of series information



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pennmarc/helpers/series.rb', line 24

def show(record, relator_map: Mappers.relator)
  tags_present = DISPLAY_TAGS.select { |tag| record[tag].present? }

  values = if %w[800 810 811 400 410 411].member?(tags_present.first)
             author_show_entries(record, tags_present.first, relator_map)
           elsif %w[830 440 490].member?(tags_present.first)
             title_show_entries(record, tags_present.first)
           end || []

  values += remaining_show_entries(record, tags_present)
  series_values = values + series_880_fields(record)
  series_values.uniq
end

.show_query_map(record) ⇒ Hash

Hash that associates 830 and 440 show values to query values to make building fielded search links easier in the downstream app.

Parameters:

  • record (MARC::Record)

Returns:

  • (Hash)


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pennmarc/helpers/series.rb', line 43

def show_query_map(record)
  record.fields(%w[830 440]).each_with_object({}) do |field, hash|
    show_values = title_show_entries(record, field.tag) + [remaining_show_value(field)]

    query_value = trim_punctuation(join_subfields(field, &subfield_in?(%w[a n p])))

    show_values.each do |show_value|
      hash[show_value] = query_value
    end
  end
end

.values(record, relator_map: Mappers.relator) ⇒ Array<String>

Values from series fields for display.

Parameters:

  • record (MARC::Record)
  • relator_map (Hash) (defaults to: Mappers.relator)

Returns:

  • (Array<String>)

    array of series values



59
60
61
62
63
64
65
# File 'lib/pennmarc/helpers/series.rb', line 59

def values(record, relator_map: Mappers.relator)
  series_8x = record.fields(%w[800 810 811 830]).first
  return Array.wrap(series_field(series_8x, relator_map)) if series_8x

  series_4x = record.fields(%w[400 410 411 440 490]).first
  Array.wrap(series_field(series_4x, relator_map)) if series_4x
end