Module: ReferenceMethods

Instance Method Summary collapse

Methods included from DOIHelpers

#a_doi, #doi_without_http, #find_doi, #url_doi

Instance Method Details

#authors_apa_6Object



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/reference_methods.rb', line 50

def authors_apa_6
  return "--NA--" if author.nil?
  authors=author.split(" and ").map {|v| v.strip}
  if authors.length>7
    author_ref=(authors[0..5]+["..."]+[authors.last]).join(", ")

  elsif authors.length>1
    author_ref=authors[0..(authors.length-2)].join(", ")+", & "+authors.last
  else
    author_ref=author
  end
  author_ref
end

#cite_apa_6Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/reference_methods.rb', line 33

def cite_apa_6
  text_authors=author.split(" and ").map {|v| v.split(",")[0]}
  n_authors=text_authors.length

  if n_authors==1
    "(#{text_authors[0]}, #{year})"
  else
    "(#{text_authors[0...(n_authors-1)].join(", ")} & #{text_authors[n_authors-1]} , #{year})"
  end

end

#ref_apa_6Object



45
46
47
48
49
# File 'lib/reference_methods.rb', line 45

def ref_apa_6
  ##$log.info("#{self.class} #{author}")
  doi_t = doi.to_s!="" ? "doi: #{doi}" : ""
  "#{author} (#{year}). #{title}. #{journal}, #{volume}, #{pages}.#{doi_t}"
end

#ref_apa_6_briefObject



63
64
65
66
67
# File 'lib/reference_methods.rb', line 63

def ref_apa_6_brief
  doi_t = doi.to_s!="" ? "doi: #{doi}" : ""
  "#{authors_apa_6} (#{year}). #{title}. #{journal}, #{volume}, #{pages}.#{doi_t}"

end

#ref_apa_6_brief_htmlObject



68
69
70
71
72
# File 'lib/reference_methods.rb', line 68

def ref_apa_6_brief_html
  doi_t = doi ? "doi: #{a_doi(doi)}" : ""
  CGI.escapeHTML("#{authors_apa_6} (#{year}). #{title}. #{journal}, #{volume}, #{pages}.")+doi_t

end