Sha256: d43990989e84b6dd55f8a5848d492ea2dd74fa45717454d6c01c6f11d9c6a078
Contents?: true
Size: 1.71 KB
Versions: 8
Compression:
Stored size: 1.71 KB
Contents
module RelatonIho class XMLParser < RelatonBib::XMLParser class << self private # Override RelatonBib::XMLParser.item_data method. # @param item [Nokogiri::XML::Element] # @returtn [Hash] def item_data(item) data = super ext = item.at "./ext" return data unless ext data[:commentperiod] = fetch_commentperiond ext data end # @param item_hash [Hash] # @return [RelatonIho::IhoBibliographicItem] def bib_item(item_hash) IhoBibliographicItem.new item_hash end # @param ext [Nokogiri::XML::Element] # @return [RelatonIho::EditorialGroupCollection, nil] def fetch_editorialgroup(ext) return unless ext egs = ext.xpath("editorialgroup").map do |eg| grps = eg.xpath("committee|workgroup|commission").map do |ig| iho_group ig end EditorialGroup.new grps end EditorialGroupCollection.new egs if egs.any? end # @param ext [Nokogiri::XML::Element. nil] # @return [RelatonIho::Committee, RelatonIho::Commission, # RelatonIho::Workgroup, nil] def iho_group(ihgrp) return unless ihgrp klass = Object.const_get "RelatonIho::" + ihgrp.name.capitalize subg = iho_group ihgrp.at("./committee|./workgroup|./commission") klass.new ihgrp.at("abbreviation").text, ihgrp.at("name")&.text, subg end # @param ext [Nokogiri::XML::Element] # @return [RelatonIho::CommentPeriod, nil] def fetch_commentperiond(ext) return unless ext && (cp = ext.at "commentperiod") CommentPeriond.new from: cp.at("from")&.text, to: cp.at("to")&.text end end end end
Version data entries
8 entries across 8 versions & 1 rubygems