Sha256: 0af8528d12a06b5509bf1195f1c11d0d86a2ddce638390b34900b8a743cfb5a9

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

module RelatonOgc
  class OgcBibliographicItem < RelatonBib::BibliographicItem
    TYPES = %w[
      abstract-specification-topic best-practice
      change-request-supporting-document
      community-practice community-standard discussion-paper engineering-report
      other policy reference-model release-notes standard user-guide white-paper
      test-suite
    ].freeze

    SUBTYPES = %w[
      conceptual-model conceptual-model-and-encoding
      conceptual-model-and-implementation encoding extension implementation
      profile profile-with-extension general
    ].freeze

    # @return [String]
    attr_reader :docsubtype

    # @param docsubtype [String]
    def initialize(**args)
      if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
        warn "[relaton-ogc] WARNING: invalid document "\
        "subtype: #{args[:docsubtype]}"
      end

      @docsubtype = args.delete :docsubtype
      super
      # @doctype = args[:doctype]
    end

    # @return [Hash]
    def to_hash
      hash = super
      hash["docsubtype"] = docsubtype if docsubtype
      hash
    end

    # @param builder [Nokogiri::XML::Builder]
    # @param opts [Hash]
    # @option opts [Boolean] :bibdata
    def to_xml(builder = nil, **opts)
      super do |b|
        b.ext do
          b.doctype doctype if doctype
          b.docsubtype docsubtype if docsubtype
          editorialgroup&.to_xml b
          ics.each { |i| i.to_xml b }
        end
      end
    end

    # @param prefix [String]
    # @return [String]
    def to_asciibib(prefix = "")
      pref = prefix.empty? ? prefix : prefix + "."
      out = super
      out += "#{pref}docsubtype:: #{docsubtype}\n" if docsubtype
      out
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-ogc-1.3.0 lib/relaton_ogc/ogc_bibliographic_item.rb