Sha256: 5e3275563ed28c0b5419803d8422aef974a0683de37242d972bc08c8b0c7ecec
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require "nokogiri" module RelatonItu class XMLParser < RelatonIsoBib::XMLParser class << self # Override RelatonIsoBib::XMLParser.form_xml method. # @param xml [String] # @return [RelatonItu::ItuBibliographicItem] def from_xml(xml) doc = Nokogiri::XML(xml) ituitem = doc.at "/bibitem|/bibdata" if ituitem ItuBibliographicItem.new item_data(ituitem) elsif warn "[relaton-itu] can't find bibitem or bibdata element in the XML" end end private # @param ext [Nokogiri::XML::Element] # @return [RelatonItu::EditorialGroup] def fetch_editorialgroup(ext) eg = ext.at("./editorialgroup") return unless eg EditorialGroup.new( bureau: eg.at("bureau")&.text, group: itugroup(eg.at("group")), subgroup: itugroup(eg.at("subgroup")), workgroup: itugroup(eg.at("workgroup")), ) end # @param com [Nokogiri::XML::Element] # @return [RelatonItu::ItuGroup] def itugroup(group) return unless group ItuGroup.new( type: group[:type], name: group.at("name").text, acronym: group.at("acronym").text, period: itugroupperiod(group.at("period")), ) end # @param com [Nokogiri::XML::Element] # @return [RelatonItu::ItuGroup::Period] def itugroupperiod(period) return until period ItuGroup::Period.new( start: period.at("start").text, finish: period.at("end")&.text, ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
relaton-itu-1.0.1 | lib/relaton_itu/xml_parser.rb |
relaton-itu-1.0.0 | lib/relaton_itu/xml_parser.rb |
relaton-itu-0.9.0 | lib/relaton_itu/xml_parser.rb |