Sha256: 2725457c70154171b4edbfa17fc1a4ee9efc8278af2a55a80b169a6e7795e8e4
Contents?: true
Size: 1.18 KB
Versions: 13
Compression:
Stored size: 1.18 KB
Contents
module RelatonNist class XMLParser < RelatonBib::XMLParser class << self def from_xml(xml) doc = Nokogiri::XML xml nistitem = doc.at("/bibitem|/bibdata") NistBibliographicItem.new(item_data(nistitem)) end private def item_data(nistitem) data = super ext = nistitem.at "./ext" return data unless ext data[:keyword] = fetch_keyword(ext) data[:commentperiod] = fetch_commentperiod(ext) data end def fetch_status(item) status = item.at "./status" return unless status DocumentStatus.new( stage: status.at("stage")&.text, substage: status.at("substage")&.text, iteration: status.at("iteration")&.text, ) end def fetch_commentperiod(item) cp = item.at "./commentperiod" return unless cp CommentPeriod.new( from: cp.at("from").text, to: cp.at("to")&.text, extended: cp.at("extended")&.text ) end def fetch_keyword(item) item.xpath("./keyword").map do |kw| Keyword.new kw.children.first.to_xml end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems