Method: Bio::MEDLINE#authors

Defined in:
lib/bio/db/medline.rb

#authorsObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/bio/db/medline.rb', line 156

def authors
  authors = []
  au.split(/\n/).each do |author|
    if author =~ / /
      name = author.split(/\s+/)
      suffix = nil
      if name.length > 2 && name[-2] =~ /^[A-Z]+$/ # second to last are the initials
        suffix = name.pop
      end
      initial = name.pop.split(//).join('. ')
      author = "#{name.join(' ')}, #{initial}."
    end
    if suffix
      author << " " + suffix
    end
    authors.push(author)
  end
  return authors
end