Method: Sufia::CitationsBehaviors::Formatters::ApaFormatter#format_authors

Defined in:
app/helpers/sufia/citations_behaviors/formatters/apa_formatter.rb

#format_authors(authors_list = []) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/sufia/citations_behaviors/formatters/apa_formatter.rb', line 32

def format_authors(authors_list = [])
  authors_list = Array.wrap(authors_list).collect { |name| abbreviate_name(surname_first(name)).strip }
  text = ''
  text << authors_list.first if authors_list.first
  authors_list[1..-1].each do |author|
    if author == authors_list.last # last
      text << ", &amp; " << author
    else # all others
      text << ", " << author
    end
  end
  text << "." unless text =~ /\.$/
  text
end