Class: PennMARC::Edition

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

Overview

Do Edition and edition-related field processing.

Constant Summary

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

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

Entry for another available edition of the target item (horizontal relationship). When a note is generated from this field, the introductory phrase Other editions available: may be generated based on the field tag for display. www.loc.gov/marc/bibliographic/bd775.html

Parameters:

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

Returns:

  • (Array<String>)

    array of other edition strings



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

def other_show(record, relator_map: Mappers.relator)
  values = record.fields('775').filter_map do |field|
    next unless subfield_defined?(field, :i)

    other_edition_value(field, relator_map)
  end
  editions = values + record.fields('880').filter_map do |field|
    next unless field.indicator2.blank? && subfield_value?(field, '6', /^775/) &&
                subfield_defined?(field, 'i')

    other_edition_value(field, relator_map)
  end
  editions.uniq
end

.show(record, with_alternate: true) ⇒ Array<String>

Edition values for display on a record page. Field 250 is information relating to the edition of a work as determined by applicable cataloging rules. For mixed materials, field 250 is used to record statements relating to collections that contain versions of works existing in two or more versions (or states) in single or multiple copies (e.g., different drafts of a film script). For continuing resources, this field is not used for sequential edition statements such as 1st- ed. This type of information is contained in field 362 (Dates of Publication and/or Volume Designation). www.loc.gov/marc/bibliographic/bd250.html

Parameters:

  • record (MARC::Record)

Returns:

  • (Array<String>)

    array of editions and their alternates



16
17
18
19
20
21
22
23
# File 'lib/pennmarc/helpers/edition.rb', line 16

def show(record, with_alternate: true)
  editions = record.fields('250').map do |field|
    join_subfields(field, &subfield_not_in?(%w[6 8]))
  end
  editions += linked_alternate_not_6_or_8(record, '250') if with_alternate

  editions.uniq
end

.values(record) ⇒ String?

Edition values for display in search results. Just grab the first 250 field.

Parameters:

  • record (MARC::Record)

Returns:

  • (String, nil)

    string of all first 250 subfields, excluding 6 and 8



28
29
30
31
32
33
# File 'lib/pennmarc/helpers/edition.rb', line 28

def values(record)
  edition = record.fields('250').first
  return if edition.blank?

  join_subfields(edition, &subfield_not_in?(%w[6 8]))
end