class QRDA::Cat1::NarrativeReferenceHandler
Public Class Methods
new()
click to toggle source
# File lib/qrda-import/narrative_reference_handler.rb, line 4 def initialize @id_map = {} end
Public Instance Methods
build_id_map(doc)
click to toggle source
# File lib/qrda-import/narrative_reference_handler.rb, line 8 def build_id_map(doc) path = "//*[@ID]" ids = doc.xpath(path) ids.each do |id| tag = id['ID'] value = id.content @id_map[tag] = value end end
lookup_tag(tag)
click to toggle source
@param [String] tag
@return [String] text description of tag
# File lib/qrda-import/narrative_reference_handler.rb, line 20 def lookup_tag(tag) value = @id_map[tag] # Not sure why, but sometimes the reference is #<Reference> and the ID value is <Reference>, and # sometimes it is #<Reference>. We look for both. if !value and tag[0] == '#' tag = tag[1,tag.length] value = @id_map[tag] end value end