Sha256: b05a54bbe0558e9160015b067b713c307062c716ee563f5ac0ba35228ec2e481

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

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

        bib = {
          bibtex_type: bibtex_type.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

1 entries across 1 versions & 1 rubygems

Version Path
bolognese-1.0.2 lib/bolognese/writers/bibtex_writer.rb