Class: PennMARC::Inventory

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

Overview

Methods for extracting holdings information (“inventory”) when available

Constant Summary collapse

PHYSICAL_INVENTORY_TAGS =
[
  Enriched::Pub::PHYS_INVENTORY_TAG,
  Enriched::Api::PHYS_INVENTORY_TAG
].freeze
ELECTRONIC_INVENTORY_TAGS =
[
  Enriched::Pub::ELEC_INVENTORY_TAG,
  Enriched::Api::ELEC_INVENTORY_TAG
].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

.electronic(record) ⇒ Array?

Hash of Electronic inventory information

Parameters:

  • record (MARC::Record)

Returns:

  • (Array, nil)


35
36
37
38
39
40
41
42
# File 'lib/pennmarc/helpers/inventory.rb', line 35

def electronic(record)
  source = enrichment_source(record)
  return unless source

  record.fields(ELECTRONIC_INVENTORY_TAGS).map do |entry|
    InventoryEntry::Electronic.new(entry, source).to_h
  end
end

.electronic_portfolio_count(record) ⇒ Integer

Count of all electronic portfolios

Parameters:

  • record (MARC::Record)

Returns:

  • (Integer)


47
48
49
# File 'lib/pennmarc/helpers/inventory.rb', line 47

def electronic_portfolio_count(record)
  record.count { |field| field.tag.in? %w[AVE prt] }
end

.physical(record) ⇒ Array?

Hash of Physical holdings information

Parameters:

  • record (MARC::Record)

Returns:

  • (Array, nil)


23
24
25
26
27
28
29
30
# File 'lib/pennmarc/helpers/inventory.rb', line 23

def physical(record)
  source = enrichment_source(record)
  return unless source

  record.fields(PHYSICAL_INVENTORY_TAGS).map do |entry|
    InventoryEntry::Physical.new(entry, source).to_h
  end
end

.physical_holding_count(record) ⇒ Integer

Count of all physical holdings

Parameters:

  • record (MARC::Record)

Returns:

  • (Integer)


54
55
56
# File 'lib/pennmarc/helpers/inventory.rb', line 54

def physical_holding_count(record)
  record.count { |field| field.tag.in? %w[AVA hld] }
end