On Feb 25, 2009, at 3:14 PM, Lars Haugseth wrote:

> * Vetrivel Vetrivel <vetrivel.bksys / gmail.com> wrote:
>>
>> I want to create new unique id in ruby.I have used the following
>> coding.But I don''t know whether it works perfectly or not.
>>
>> t =3D Time.new
>> p "%10.5f" % t.to_f
>>
>> does it give unique value always.I you know some other way ,please =20=

>> say
>> to create unique id .
>
> UUID=B9 is a standard way of constructing unique identifiers, and a =
Ruby
> library=B2 exist already, so unless you require the identifiers to be
> integers, I suggest you use that.
>
> [1] http://en.wikipedia.org/wiki/UUID
> [2] http://wiki.github.com/assaf/uuid
>
> --=20
> Lars Haugseth
>
> "If anyone disagrees with anything I say, I am quite prepared not =20
> only to
> retract it, but also to deny under oath that I ever said it." -Tom =20
> Lehrer
>

UUIDs can also be notated in an integer representation. It's just a =20
bit long.

There are multiple libraries, this example uses the gem uuidtools:

 >> UUID.timestamp_create.to_i
227941543066369752189048382045440381927

They are the best way to choose.

Regards,
Florian

--
Florian Gilcher

smtp:   flo / andersground.net
jabber: Skade / jabber.ccc.de
gpg:    533148E2