Sha256: fbfb36717aa05d9a1b45fd6d4a701e8efff95fe46013964672dc5406dfaef350
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 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, nil] # @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 ihgrp [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 def create_doctype(type) DocumentType.new type: type.text, abbreviation: type[:abbreviation] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
relaton-iho-1.20.0 | lib/relaton_iho/xml_parser.rb |
relaton-iho-1.19.1 | lib/relaton_iho/xml_parser.rb |
relaton-iho-1.19.0 | lib/relaton_iho/xml_parser.rb |