Module: Researchmap2bib::Utils
- Included in:
- Generator
- Defined in:
- lib/researchmap2bib/utils.rb
Instance Method Summary collapse
- #concatenate_authors(authors) ⇒ Object
- #family_name(author) ⇒ Object
- #first_author(authors) ⇒ Object
- #to_hankaku(str) ⇒ Object
- #year_month(date) ⇒ Object
Instance Method Details
#concatenate_authors(authors) ⇒ Object
12 13 14 |
# File 'lib/researchmap2bib/utils.rb', line 12 def () .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() if /(^\w*) +(\w*)$/ =~ $2 elsif /(^\S*) +(\S*)$/ =~ $1 else end end |
#first_author(authors) ⇒ Object
16 17 18 19 |
# File 'lib/researchmap2bib/utils.rb', line 16 def () r = /([^,]*)/.match() r == nil ? .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 |