Sha256: d99af2844d1c9fe2ce6ebc6f7e6381c8173416fbc1aa40f05c9808f1bc9db8fc

Contents?: true

Size: 1016 Bytes

Versions: 3

Compression:

Stored size: 1016 Bytes

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[: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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
relaton-nist-0.8.0 lib/relaton_nist/xml_parser.rb
relaton-nist-0.7.0 lib/relaton_nist/xml_parser.rb
relaton-nist-0.6.0 lib/relaton_nist/xml_parser.rb