module Researchmap2bib::Utils

Public Instance Methods

concatenate_authors(authors) click to toggle source
# File lib/researchmap2bib/utils.rb, line 12
def concatenate_authors(authors)
  authors.gsub(/ *, */, ' and ')
end
family_name(author) click to toggle source
# File lib/researchmap2bib/utils.rb, line 21
def family_name(author)
  if /(^\w*) +(\w*)$/ =~ author
    $2
  elsif /(^\S*) +(\S*)$/ =~ author
    $1
  else
    author
  end
end
first_author(authors) click to toggle source
# File lib/researchmap2bib/utils.rb, line 16
def first_author(authors)
  r = /([^,]*)/.match(authors)
  r == nil ? authors.strip : r.captures[0].strip
end
to_hankaku(str) click to toggle source
# File lib/researchmap2bib/utils.rb, line 4
def to_hankaku(str)
  str.tr('0-9a-zA-Z,、 ', '0-9a-zA-Z,, ')
end
year_month(date) click to toggle source
# File lib/researchmap2bib/utils.rb, line 8
def year_month(date)
  /([0-9]{4})([0-9]{2})/.match(date).captures
end