Sha256: 1c098883e11db23c7271daa3b8ea14082e75fb7bdcfe593374fe730b9be25739
Contents?: true
Size: 1.21 KB
Versions: 13
Compression:
Stored size: 1.21 KB
Contents
require "nokogiri" module RelatonGb class XMLParser < RelatonIsoBib::XMLParser class << self def from_xml(xml) doc = Nokogiri::XML(xml) gbitem = doc.at "/bibitem|/bibdata" GbBibliographicItem.new item_data(gbitem) end private def item_data(gbitem) data = super data[:committee] = fetch_committee gbitem data[:gbtype] = fetch_gbtype gbitem data[:ccs] = fetch_ccs gbitem data[:plannumber] = gbitem.at("./plannumber")&.text data end # Overrade get_id from RelatonIsoBib::XMLParser # def get_id(did) # did.text.match(/^(?<project>.*?\d+)(?<hyphen>-)?(?(<hyphen>)(?<year>\d*))/) # end def fetch_committee(doc) committee = doc.at "./ext/gbcommittee" return nil unless committee { type: committee[:type], name: committee.text } end def fetch_ccs(doc) doc.xpath("./ext/ccs/code").map &:text end def fetch_gbtype(doc) gbtype = doc.at "./ext/gbtype" { scope: gbtype&.at("gbscope")&.text, prefix: gbtype&.at("gbprefix")&.text, mandate: gbtype&.at("gbmandate")&.text, } end end end end
Version data entries
13 entries across 13 versions & 1 rubygems