Sha256: 0de54e8e2f345e6762d5320b6a0ca4c3d536e94e676aaa56aec431b57f7952d5

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require "nokogiri"

module RelatonOgc
  class XMLParser < RelatonIsoBib::XMLParser
    class << self
      private

      # override RelatonIsoBib::IsoBibliographicItem.bib_item method
      # @param item_hash [Hash]
      # @return [RelatonOgc::OgcBibliographicItem]
      def bib_item(item_hash)
        OgcBibliographicItem.new **item_hash
      end

      # Override RelatonIsoBib::XMLParser.item_data method.
      # @param item [Nokogiri::XML::Element]
      # @returtn [Hash]
      def item_data(item)
        data = super
        ext = item.at "./ext"
        return data unless ext

        data[:docsubtype] = ext.at("./docsubtype")&.text
        data
      end

      # @TODO Organization doesn't recreated
      # @param ext [Nokogiri::XML::Element]
      # @return [RelatonIsoBib::EditorialGroup]
      def fetch_editorialgroup(ext)
        eg = ext.at("./editorialgroup")
        return unless eg

        committe = eg&.at("committee")&.text
        sc = iso_subgroup eg&.at("subcommittee")
        wg = iso_subgroup eg&.at("workgroup")
        EditorialGroup.new(
          committee: committe, subcommittee: sc, workgroup: wg
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
relaton-ogc-1.8.0 lib/relaton_ogc/xml_parser.rb
relaton-ogc-1.7.3 lib/relaton_ogc/xml_parser.rb
relaton-ogc-1.7.2 lib/relaton_ogc/xml_parser.rb
relaton-ogc-1.7.1 lib/relaton_ogc/xml_parser.rb