Class: DiscoveryIndexer::InputXml::Modsxml

Inherits:
Object
  • Object
show all
Defined in:
lib/discovery-indexer/reader/modsxml.rb

Overview

This class is the main class to access and parse the mods xml

as retrieved from PURL server

Examples:

to run the code

druid = "aa111aa1111"
p =  DiscoveryIndexer::InputXml::Modsxml.new(druid)
model =  p.load()

Instance Method Summary collapse

Constructor Details

#initialize(druid) ⇒ Modsxml

initializes a new object

Parameters:

  • druid (String)

    the druid object in the format “aa111aa1111”



15
16
17
18
# File 'lib/discovery-indexer/reader/modsxml.rb', line 15

def initialize(druid)
  @druid = druid
  @modsxml_ng_doc = nil
end

Instance Method Details

#loadStanford::Mods::Record

loads the mods xml to stanford mods model for the fedora object defind in the druid, it reads the mods xml once from PURL server, and repeat the parsing with each call

Returns:

  • (Stanford::Mods::Record)

    represents the mods xml



23
24
25
26
27
28
# File 'lib/discovery-indexer/reader/modsxml.rb', line 23

def load
  @modsxml_ng_doc = ModsxmlReader.read(@druid) if @modsxml_ng_doc.nil?

  modsxml_model = Stanford::Mods::Record.new
  modsxml_model.from_nk_node(@modsxml_ng_doc)
end