Module: Serializers::EndNote

Included in:
Document
Defined in:
lib/serializers/end_note.rb

Overview

Convert a document to an EndNote record

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)

Register this serializer in the Document list



9
10
11
12
13
14
15
# File 'lib/serializers/end_note.rb', line 9

def self.included(base)
  base.register_serializer(
    :endnote, 'EndNote',
    ->(doc) { doc.to_endnote },
    'http://auditorymodels.org/jba/bibs/NetBib/Tools/bp-0.2.97/doc/endnote.html'
  )
end

Instance Method Details

- (String) to_endnote

Returns this document as an EndNote record

Examples:

Download this document as a enw file

controller.send_data doc.to_endnote, filename: 'export.enw',
                     disposition: 'attachment'

Returns:

  • (String)

    document in EndNote format



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/serializers/end_note.rb', line 24

def to_endnote
  ret  = "%0 Journal Article\n"
  if formatted_author_list && formatted_author_list.count
    formatted_author_list.each do |a|
      ret << "%A #{a.last}, #{a.first}"
      ret << " #{a.von}" unless a.von.blank?
      ret << ", #{a.suffix}" unless a.suffix.blank?
      ret << "\n"
    end
  end
  ret << "%T #{title}\n" unless title.blank?
  ret << "%D #{year}\n" unless year.blank?
  ret << "%J #{journal}\n" unless journal.blank?
  ret << "%V #{volume}\n" unless volume.blank?
  ret << "%N #{number}\n" unless number.blank?
  ret << "%P #{pages}\n" unless pages.blank?
  ret << "%M #{doi}\n" unless doi.blank?
  ret << "\n"
  ret
end