Sha256: 1f24e77d8fa9e4372772905f3a2a444835986a25b9d919c8a32d258202f4d125
Contents?: true
Size: 1.26 KB
Versions: 21
Compression:
Stored size: 1.26 KB
Contents
module Ddr module Models # # Wraps a Nokogiri (XML) Document # class Structure < SimpleDelegator def initialize(xml_doc=nil) super end def struct_maps @struct_maps ||= build_struct_maps(structMap_nodes) end def structMap_node(type='default') xpath("//xmlns:structMap[@TYPE='#{type}']").first end def fptr_nodes(type='default') structMap_node(type).xpath('//xmlns:fptr') end def as_xml_document __getobj__ end private def structMap_nodes xpath("//xmlns:structMap") end def build_struct_maps(structMap_nodes) smaps = {} structMap_nodes.each do |structMap_node| type = structMap_node['TYPE'] || 'default' raise StandardError, "Multiple '#{type}' structMaps" if smaps[type].present? smaps[type] = Ddr::Models::StructDiv.new(structMap_node) end smaps end def self.template Nokogiri::XML( '<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink"> <structMap TYPE="default" /> </mets>' ) do |config| config.noblanks end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems