class NewspaperWorks::Ingest::NDNP::IssueMetadata
Attributes
doc[RW]
parent[RW]
path[RW]
Public Class Methods
new(path, parent = nil)
click to toggle source
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 9 def initialize(path, parent = nil) @path = path @parent = parent @doc = nil load_doc end
Public Instance Methods
edition_name()
click to toggle source
Edition name
Edition name is optional ("caption" / "label") is optional in NDNP, but as it may be used as a label for readability.
@return [String,NilClass]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 50 def edition_name ed_name = xpath("//mods:detail[@type='edition']/mods:caption") return ed_name.text unless ed_name.size.zero? end
edition_number()
click to toggle source
Edition name, with fallback to edition number (mandatory) @return [String]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 57 def edition_number xpath("//mods:detail[@type='edition']/mods:number").text end
held_by()
click to toggle source
Original Source Repository (NDNP-mandatory) @return [String]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 83 def held_by xpath("//mods:physicalLocation").first['displayLabel'] end
inspect()
click to toggle source
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 16 def inspect format( "<#{self.class}:0x000000000%<oid>x\n" \ "\tpath: '#{path}',\n", oid: object_id << 1 ) end
issue_number()
click to toggle source
Issue number (optional) @return [String,NilClass]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 40 def issue_number result = xpath("//mods:detail[@type='issue']/mods:number") return if result.size.zero? result.text end
lccn()
click to toggle source
LCCN (mandatory) @return [String]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 26 def lccn xpath("//mods:identifier[@type='lccn']").text end
publication_date()
click to toggle source
Issue date (mandatory field) as ISO 8601 datestamp string @return [String] (ISO-8601 date) publication date
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 63 def publication_date xpath("//mods:originInfo/mods:dateIssued").text end
publication_title()
click to toggle source
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 67 def publication_title # try from reel first reel = parent.nil? ? nil : parent.container return reel.metadata.title unless reel.nil? # fallback to parsing //mets/@LABEL label = xpath('//mets:mets/@LABEL').first v = label.nil? ? '' : label.value.split(/[,] [0-9]/)[0] # based on label convention: # "ACME Times (Springfield, UT), 1911-01-25, First Edition" # Returns the name and (*for now TBD*) place of publication # as a string in parentheses. v.split(/, [0-9]/)[0] end
volume()
click to toggle source
Volume number (optional) @return [String,NilClass]
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 32 def volume result = xpath("//mods:detail[@type='volume']/mods:number") return if result.size.zero? result.text end
Private Instance Methods
load_doc()
click to toggle source
# File lib/newspaper_works/ingest/ndnp/issue_metadata.rb, line 89 def load_doc @doc = @parent.doc unless @parent.nil? @doc = Nokogiri::XML(File.open(path)) if @doc.nil? end