Module: Researchmap2bib::UniqueId

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

Constant Summary collapse

@@id_to_entry =
Hash.new

Instance Method Summary collapse

Instance Method Details

#unique_id(key) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/researchmap2bib/unique_id.rb', line 6

def unique_id(key)
  if @@id_to_entry[key]
    i = 2
    begin
      new_key = key + ':' + i.to_s
      i += 1
    end while @@id_to_entry[new_key]
    @@id_to_entry[new_key] = true
    return new_key
  else
    @@id_to_entry[key] = true
    return key
  end
end