Sha256: 0d16c03aa5a0b51747b531bdc303f0eaf886079f4bff261b2da7545ddcfe581a

Contents?: true

Size: 997 Bytes

Versions: 15

Compression:

Stored size: 997 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

15 entries across 15 versions & 1 rubygems

Version Path
relaton-ietf-1.1.3 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.1.2 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.1.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.1.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.0.4 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.0.3 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.0.2 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.0.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.0.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.12.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.12.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.11.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.11.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.10.0 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-0.9.0 lib/relaton_ietf/ietf_bibliographic_item.rb