Sha256: 88055c199be77ee659303fbaa8514d39527f0e85bb6e57ba1e819637c9caa803

Contents?: true

Size: 991 Bytes

Versions: 13

Compression:

Stored size: 991 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
      @keyword = args.delete(:keyword) || []
      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]
          b.ext do
            b.doctype doctype if doctype
            keyword.each { |k| b.keyword k }
          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

13 entries across 13 versions & 1 rubygems

Version Path
relaton-ietf-0.8.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.7.3 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.7.2 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.7.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.7.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.10 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.9 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.8 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.7 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.6 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.5 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.4 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.6.3 lib/relaton_ietf/ietf_bibliographic_item.rb