Class: GenerateId
Instance Method Summary collapse
-
#initialize(&already_exist) ⇒ GenerateId
constructor
A new instance of GenerateId.
Constructor Details
#initialize(&already_exist) ⇒ GenerateId
Returns a new instance of GenerateId.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generate_id.rb', line 11 def initialize ( &already_exist ) md5 = Digest::MD5::new id = '' begin md5.update(id) md5.update(Time.now.to_s) md5.update(rand.to_s) md5.update($$.to_s) md5.update($0) id = md5.hexdigest[0,16] end while block_given? and already_exist[id] id end |