class NistBib::XMLParser
Public Class Methods
from_xml(xml)
click to toggle source
# File lib/nistbib/xml_parser.rb, line 4 def from_xml(xml) doc = Nokogiri::XML xml nistitem = doc.at("/bibitem|/bibdata") NistBibliographicItem.new(item_data(nistitem)) end
Private Class Methods
fetch_commentperiod(item)
click to toggle source
# File lib/nistbib/xml_parser.rb, line 33 def fetch_commentperiod(item) cp = item.at "./commentperiod" return unless cp CommentPeriod.new cp.at("from").text, cp.at("to")&.text, cp.at("extended")&.text end
fetch_keyword(item)
click to toggle source
# File lib/nistbib/xml_parser.rb, line 40 def fetch_keyword(item) item.xpath("./keyword").map do |kw| Keyword.new kw.children.first.to_xml end end
fetch_status(item)
click to toggle source
# File lib/nistbib/xml_parser.rb, line 22 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
item_data(nistitem)
click to toggle source
Calls superclass method
# File lib/nistbib/xml_parser.rb, line 12 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