Module: Bolognese::Writers::BibtexWriter

Included in:
Metadata
Defined in:
lib/bolognese/writers/bibtex_writer.rb

Instance Method Summary collapse

Instance Method Details

#bibtexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bolognese/writers/bibtex_writer.rb', line 4

def bibtex
  return nil unless valid?

  bib = {
    bibtex_type: bibtex_type.presence || "misc",
    bibtex_key: id,
    doi: doi,
    url: url,
    author: authors_as_string(author),
    keywords: Array.wrap(parse_attributes(keywords, content: "text")).join(", "),
    language: language,
    title: parse_attributes(title, content: "text", first: true),
    journal: container_title,
    volume: volume,
    issue: issue,
    pages: pagination,
    publisher: publisher,
    year: publication_year
  }.compact
  BibTeX::Entry.new(bib).to_s
end