Class: BibliographicalImporter::BibTex::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/bibliographical_importer/bibtex.rb

Class Method Summary collapse

Class Method Details

.generate(canonical_documents) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/bibliographical_importer/bibtex.rb', line 306

def self.generate(canonical_documents)
  bib = BibTeX::Bibliography.new
  canonical_documents.each do |cd|
    campos=[:title, :abstract, :journal, :year, :volume, :pages,
         :doi, :url, :author, :scopus_id, :wos_id, :scielo_id]

    hash_c=campos.inject({}) {|ac,v|
      ac[v]=cd.send(v)
      ac
    }
    hash_c[:bibtex_type]=:article
    hash_c[:key]="key_#{cd[:id]}_#{cd[:year]}"
    bib << BibTeX::Entry.new(hash_c)

  end

  bib
end