Class: DiscoveryIndexer::InputXml::Purlxml

Inherits:
Object
  • Object
show all
Defined in:
lib/reader/purlxml.rb

Overview

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

as retrieved from PURL server

Examples:

to run the code

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

Instance Method Summary collapse

Constructor Details

#initialize(druid) ⇒ Purlxml

initializes a new object

Parameters:

  • druid (String)

    the druid object in the format “aa111aa1111”



12
13
14
15
# File 'lib/reader/purlxml.rb', line 12

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

Instance Method Details

#loadPurlxmlModel

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

Returns:



20
21
22
23
24
25
# File 'lib/reader/purlxml.rb', line 20

def load
  @purlxml_ng_doc = PurlxmlReader.read(@druid) if @purlxml_ng_doc.nil?
  purlxml_parser = PurlxmlParserStrict.new(@druid, @purlxml_ng_doc)
  purlxml_model = purlxml_parser.parse
  purlxml_model
end

#reloadPurlxmlModel

loads the purl xml to purlxml model for the fedora object defind in the druid it reads the purl xml from PURL server with every call

Returns:



30
31
32
33
# File 'lib/reader/purlxml.rb', line 30

def reload
  @purlxml_ng_doc = PurlxmlReader.read(@druid)
  load
end