Sha256: 2768d3bed01b1388b019b30b4240ab7d8586b2aa9bc19d41efb98a89dcf11e23

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module Bolognese
  module Writers
    module BibtexWriter
      def bibtex
        return nil unless valid?

        bib = {
          bibtex_type: types["bibtex"].presence || "misc",
          bibtex_key: identifier,
          doi: doi,
          url: url,
          author: authors_as_string(creators),
          keywords: subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.join(", ") : nil,
          language: language,
          title: parse_attributes(titles, content: "title", first: true),
          journal: periodical && periodical["title"],
          volume: volume,
          issue: issue,
          pages: [first_page, last_page].compact.join("-").presence,
          publisher: publisher,
          year: publication_year
        }.compact
        BibTeX::Entry.new(bib).to_s
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bolognese-1.0.29 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.28 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.27 lib/bolognese/writers/bibtex_writer.rb