class NewspaperWorks::Ingest::NDNP::ContainerMetadata

Attributes

doc[RW]
path[RW]

Public Class Methods

new(path, parent = nil) click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 9
def initialize(path, parent = nil)
  @path = path
  @parent = parent
  @doc = nil
  load_doc
end

Public Instance Methods

genre() click to toggle source

Media genre/form (Page Physical Description, e.g. “microform”)

NDNP Mandatory.

@return [String]

# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 49
def genre
  form = xpath('//mods:physicalDescription/MODS:form').first
  form.attributes['type'].value
end
held_by() click to toggle source

Original Source Repository (NDNP-mandatory) @return [String]

# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 35
def held_by
  v = xpath("//mods:physicalLocation").first
  return v['displayLabel'] unless v.nil?
  # fallback to look at mods:note/@displayLabel, when the
  #   @type="agencyResponsibleForReproduction"
  xpath(
    '//mods:note[@type="agencyResponsibleForReproduction"]' \
    '/@displayLabel'
  ).first.value
end
inspect() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 16
def inspect
  format(
    "<#{self.class}:0x000000000%<oid>x\n" \
      "\tpath: '#{path}',\n",
    oid: object_id << 1
  )
end
publication_date_end() click to toggle source

End Date (optional) @return [String] ISO 8601 formatted date

# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 68
def publication_date_end
  techmd('ndnp:endDate')
end
publication_date_start() click to toggle source

Start Date (optional) @return [String] ISO 8601 formatted date

# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 62
def publication_date_start
  techmd('ndnp:startDate')
end
reel_number() click to toggle source

Reel Number (NDNP-mandatory) @return [String] a serial number string for reel, may correspond

to an issued barcode
# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 27
def reel_number
  v = xpath("//mods:identifier[@type='reel number']").first
  return v.text unless v.nil?
  xpath('//mets:mets/@LABEL').first.value
end
title() click to toggle source

Titles (on Reel) (optional) @return [String] title

# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 56
def title
  techmd('ndnp:titles')
end

Private Instance Methods

load_doc() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 74
def load_doc
  @doc = @parent.doc unless @parent.nil?
  @doc = Nokogiri::XML(File.open(path)) if @doc.nil?
end
techmd(spec = nil) click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_metadata.rb, line 79
def techmd(spec = nil)
  base = xpath('//ndnp:reelTechMD')
  return base if spec.nil?
  base.xpath(spec).first.text
end