Sha256: 3e4f4fb0f79faf39369f6a08e0aadef81dc511fd45d4983ef7b6a44eac55751c

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module RelatonIetf
  class IetfBibliographicItem < RelatonBib::BibliographicItem
    DOCTYPES = %w[rfc internet-draft].freeze

    # @return [String, NilClass]
    attr_reader :doctype

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

    # @param doctype [String]
    # @param keyword [Array<String>]
    def initialize(**args)
      if args[:doctype] && !DOCTYPES.include?(args[:doctype])
        warn "[relaton-ietf] WARNING: invalid doctype #{args[:doctype]}"
      end
      super
    end

    # @param hash [Hash]
    # @return [RelatonIetf::IetfBibliographicItem]
    def self.from_hash(hash)
      item_hash = ::RelatonIetf::HashConverter.hash_to_bib(hash)
      new(**item_hash)
    end

    # @param opts [Hash]
    # @option opts [Nokogiri::XML::Builder] :builder XML builder
    # @option opts [Boolean] :bibdata
    # @option opts [Symbol, NilClass] :date_format (:short), :full
    # @option opts [String, Symbol] :lang language
    # @return [String] XML
    def to_xml(**opts)
      opts[:date_format] ||= :short
      super(**opts)
    end

    #
    # Render date as BibXML
    #
    # @param [Nokogiri::XML::Builder] builder xml builder
    #
    def render_date(builder)
      return if docidentifier.detect { |i| i.type == "IANA" }

      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
relaton-ietf-1.13.10 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.13.9 lib/relaton_ietf/ietf_bibliographic_item.rb