Class: RelatonBib::Renderer::BibtexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/renderer/bibtex_builder.rb

Constant Summary collapse

ATTRS =
%i[
  type id title author editor booktitle series number edition contributor
  date address note relation extent classification keyword docidentifier
  timestamp link
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bib) ⇒ BibtexBuilder

Initialize BibTeX builder.

Parameters:



44
45
46
# File 'lib/relaton_bib/renderer/bibtex_builder.rb', line 44

def initialize(bib)
  @bib = bib
end

Class Method Details

.build(bib, bibtex = nil) ⇒ BibTeX::Bibliography

Build BibTeX bibliography.

Parameters:

Returns:

  • (BibTeX::Bibliography)

    BibTeX bibliography



36
37
38
# File 'lib/relaton_bib/renderer/bibtex_builder.rb', line 36

def self.build(bib, bibtex = nil)
  new(bib).build bibtex
end

Instance Method Details

#build(bibtex = nil) ⇒ BibTeX::Bibliography

Build BibTeX bibliography.

Parameters:

  • bibtex (BibTeX::Bibliography, nil) (defaults to: nil)

    BibTeX bibliography

Returns:

  • (BibTeX::Bibliography)

    BibTeX bibliography



55
56
57
58
59
60
61
# File 'lib/relaton_bib/renderer/bibtex_builder.rb', line 55

def build(bibtex = nil)
  @item = BibTeX::Entry.new
  ATTRS.each { |a| send("add_#{a}") }
  bibtex ||= BibTeX::Bibliography.new
  bibtex << @item
  bibtex
end