Class: Sufia::CitationsBehaviors::Formatters::EndnoteFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Sufia::CitationsBehaviors::Formatters::EndnoteFormatter
- Defined in:
- app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from BaseFormatter
Methods included from NameBehavior
#abbreviate_name, #all_authors, #author_list, #given_name_first, #surname_first
Methods included from CommonBehavior
#clean_end_punctuation, #persistent_url
Constructor Details
This class inherits a constructor from Sufia::CitationsBehaviors::Formatters::BaseFormatter
Instance Method Details
#end_note_format ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb', line 23 def end_note_format { '%T' => [:title, ->(x) { x.first }], '%Q' => [:title, ->(x) { x.drop(1) }], '%A' => [:creator], '%C' => [:publication_place], '%D' => [:date_created], '%8' => [:date_uploaded], '%E' => [:contributor], '%I' => [:publisher], '%J' => [:series_title], '%@' => [:isbn], '%U' => [:related_url], '%7' => [:edition_statement], '%R' => persistent_url(work), '%X' => [:description], '%G' => [:language], '%[' => [:date_modified], '%9' => [:resource_type], '%~' => view_context.application_name, '%W' => view_context.institution_name } end |
#format(work) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb', line 5 def format(work) text = [] text << "%0 GenericFile" end_note_format.each do |endnote_key, mapping| if mapping.is_a? String values = [mapping] else values = work.send(mapping[0]) if work.respond_to? mapping[0] values = mapping[1].call(values) if mapping.length == 2 values = Array.wrap(values) end next if values.empty? || values.first.nil? spaced_values = values.join("; ") text << "#{endnote_key} #{spaced_values}" end text.join("\n") end |