Module: Researchmap2bib::Utils

Included in:
Generator
Defined in:
lib/researchmap2bib/utils.rb

Instance Method Summary collapse

Instance Method Details

#concatenate_authors(authors) ⇒ Object



12
13
14
# File 'lib/researchmap2bib/utils.rb', line 12

def concatenate_authors(authors)
  authors.gsub(/ *, */, ' and ')
end

#family_name(author) ⇒ Object



21
22
23
24
25
26
27
28
29
# 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) ⇒ Object



16
17
18
19
# 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) ⇒ Object



4
5
6
# 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) ⇒ Object



8
9
10
# File 'lib/researchmap2bib/utils.rb', line 8

def year_month(date)
  /([0-9]{4})([0-9]{2})/.match(date).captures
end