Sha256: 2ceed88eefa970561d5046eff0001267bc5e72f3e596939d552bff3641ed34c8

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

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

    #
    # Fetch flavor schema version
    #
    # @return [String] schema version
    #
    def ext_schema
      @ext_schema ||= schema_versions["relaton-model-ietf"]
    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.14.1 lib/relaton_ietf/ietf_bibliographic_item.rb
relaton-ietf-1.14.0 lib/relaton_ietf/ietf_bibliographic_item.rb