Class: NewspaperWorks::Ingest::NDNP::IssueIngest

Inherits:
Object
  • Object
show all
Includes:
Enumerable, NDNPMetsHelper
Defined in:
lib/newspaper_works/ingest/ndnp/issue_ingest.rb

Constant Summary

Constants included from NDNPMetsHelper

NDNPMetsHelper::XML_NS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NDNPMetsHelper

#container, #container_path, #dmd_node, #normalize_path, #page_files, #xpath

Constructor Details

#initialize(path) ⇒ IssueIngest

Returns a new instance of IssueIngest.



10
11
12
13
14
15
16
17
18
19
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 10

def initialize(path)
  @path = path
  @doc = nil
  @metadata = nil
  # Enumeration based on list of DMDID loaded by load_doc
  @dmdids = nil
  load_doc
  # cache dmdid -> PageIngest
  @page_cache = {}
end

Instance Attribute Details

#dmdidsObject

Returns the value of attribute dmdids.



8
9
10
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 8

def dmdids
  @dmdids
end

#docObject

Returns the value of attribute doc.



8
9
10
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 8

def doc
  @doc
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 8

def path
  @path
end

Instance Method Details

#eachObject



50
51
52
53
54
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 50

def each
  @dmdids.each do |dmdid|
    yield page_by_dmdid(dmdid)
  end
end

#identifierObject



29
30
31
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 29

def identifier
  .lccn
end

#inspectObject



21
22
23
24
25
26
27
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 21

def inspect
  format(
    "<#{self.class}:0x000000000%<oid>x\n" \
      "\tpath: '#{path}',\n",
    oid: object_id << 1
  )
end

#metadataObject



60
61
62
63
64
65
66
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 60

def 
  return @metadata unless @metadata.nil?
  @metadata = NewspaperWorks::Ingest::NDNP::IssueMetadata.new(
    path,
    self
  )
end

#page_by_dmdid(dmdid) ⇒ Object



33
34
35
36
37
38
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 33

def page_by_dmdid(dmdid)
  return @page_cache[dmdid] if @page_cache.key?(dmdid)
  p = NewspaperWorks::Ingest::NDNP::PageIngest.new(@path, dmdid, self)
  @page_cache[dmdid] = p
  p
end

#page_by_sequence_number(n) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 40

def page_by_sequence_number(n)
  page_by_dmdid(
    doc.xpath(
      "//mods:extent//mods:start[text()='#{n}']",
      mets: 'http://www.loc.gov/METS/',
      mods: 'http://www.loc.gov/mods/v3'
    ).first.ancestors('dmdSec').first['ID']
  )
end

#sizeObject



56
57
58
# File 'lib/newspaper_works/ingest/ndnp/issue_ingest.rb', line 56

def size
  @dmdids.size
end