Sha256: f8af8e1e7d08864ecc135f53e8e318b4334a4444a9fb89f1a7290dd2ea7623f4

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

module RelatonIetf
  class IetfBibliographicItem < RelatonBib::BibliographicItem
    # @return [String, NilClass]
    attr_reader :doctype

    # @return [Array<String>]
    attr_reader :keyword

    # @param doctype [String]
    # @param keyword [Array<String>]
    def initialize(**args)
      @doctype = args.delete :doctype
      super
    end

    # @param builder
    # @param opts [Hash]
    # @option opts [Symbol, NilClass] :date_format (:short), :full
    def to_xml(builder = nil, **opts)
      opts[:date_format] ||= :short
      super builder, **opts do |b|
        if opts[:bibdata] && doctype
          b.ext do
            b.doctype doctype if doctype
          end
        end
      end
    end

    # @return [Hash]
    def to_hash
      hash = super
      hash["doctype"] = doctype if doctype
      # hash["keyword"] = single_element_array(keyword) if keyword&.any?
      hash
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-ietf-1.1.4 lib/relaton_ietf/ietf_bibliographic_item.rb