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

Class Method 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
# 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
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

Class Method Details

.from_hash(hash) ⇒ RelatonIetf::IetfBibliographicItem

Parameters:

  • hash (Hash)

Returns:



22
23
24
25
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 22

def self.from_hash(hash)
  item_hash = ::RelatonIetf::HashConverter.hash_to_bib(hash)
  new(**item_hash)
end

Instance Method Details

#to_xml(**opts) ⇒ String

Returns XML.

Parameters:

  • opts (Hash)

Options Hash (**opts):

  • :builder (Nokogiri::XML::Builder)

    XML builder

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

    , :full

  • :lang (String, Symbol)

    language

Returns:

  • (String)

    XML



33
34
35
36
# File 'lib/relaton_ietf/ietf_bibliographic_item.rb', line 33

def to_xml(**opts)
  opts[:date_format] ||= :short
  super(**opts)
end