Class: RelatonIetf::IetfBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_ietf/ietf_bibliographic_item.rb

Constant Summary collapse

DOCTYPES =
%w[rfc internet-draft].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ IetfBibliographicItem

Returns a new instance of IetfBibliographicItem.

Parameters:

  • doctype (String)
  • keyword (Array<String>)


13
14
15
16
17
18
19
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 13

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

Instance Attribute Details

#doctypeString, NilClass (readonly)

Returns:

  • (String, NilClass)


6
7
8
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 6

def doctype
  @doctype
end

#keywordArray<String> (readonly)

Returns:

  • (Array<String>)


9
10
11
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 9

def keyword
  @keyword
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


36
37
38
39
40
41
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 36

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

#to_xml(builder = nil, **opts) ⇒ Object

Parameters:

  • builder (defaults to: nil)
  • opts (Hash)

Options Hash (**opts):

  • :date_format (Symbol, NilClass) — default: :short

    , :full



24
25
26
27
28
29
30
31
32
33
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 24

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