Sha256: c8cdab5b92c3401166997b97965a2f225038ef2114b5c522f402ca3f5750c46e

Contents?: true

Size: 898 Bytes

Versions: 4

Compression:

Stored size: 898 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(creator),
          keywords: keywords.present? ? Array.wrap(keywords).map { |k| parse_attributes(k, content: "text", first: true) }.join(", ") : nil,
          language: language,
          title: parse_attributes(title, content: "text", 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

4 entries across 4 versions & 1 rubygems

Version Path
bolognese-1.0.6 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.5 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.4 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.3 lib/bolognese/writers/bibtex_writer.rb