Sha256: 0d4bf864d5c777b94fc41552671c0a2e394a992de9e33855c38c3d7528bae84a

Contents?: true

Size: 903 Bytes

Versions: 16

Compression:

Stored size: 903 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: 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

16 entries across 16 versions & 1 rubygems

Version Path
bolognese-1.0.26 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.25 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.24 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.23 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.21 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.20 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.19 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.16 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.15 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.13 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.12 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.11 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.10 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.9 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.8 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.0.7 lib/bolognese/writers/bibtex_writer.rb