[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problems using UUID (universally unique identifier

Pablo Q.

6/12/2008 5:19:00 PM

Hi all,

I need to generate uuid numbers. I try to run this:

require_gem 'uuid'


10.times do
p UUID.new
end

But I'm receiving this:

183260c1-1ad1-012b-bfbf-001c23187f94
uuid.rb:1:Warning: require_gem is obsolete. Use gem instead.
UUID: Initialized UUID generator with sequence number 0xbfbf and MAC addres=
s
00-1C-23-18-7F-94

So I change require_gem with gem. Now I'm receiving this:

uuid.rb:3: uninitialized constant UUID (NameError)

Tool completed with exit code 1

What am I doing wrong?

--=20
Pablo Quir=F3s Sol=EDs

2 Answers

Avdi Grimm

6/12/2008 5:28:00 PM

0

On Thu, Jun 12, 2008 at 1:19 PM, Pablo Q. <paqs140482@gmail.com> wrote:
> What am I doing wrong?

Just use require:

require 'uuid'

--
Avdi

Home: http:...
Developer Blog: http:.../devblog/
Twitter: http://twitte...
Journal: http://avdi.livej...

Rob Biedenharn

6/12/2008 6:05:00 PM

0

On Jun 12, 2008, at 1:27 PM, Avdi Grimm wrote:
> On Thu, Jun 12, 2008 at 1:19 PM, Pablo Q. <paqs140482@gmail.com>
> wrote:
>> What am I doing wrong?
>
> Just use require:
>
> require 'uuid'
>
> --
> Avdi
>
> Home: http:...
> Developer Blog: http:.../devblog/
> Twitter: http://twitte...
> Journal: http://avdi.livej...

Or perhaps:

require 'rubygems'
require 'uuid'

If you ever needed a specific version of UUID, you could add a gem
statement:

require 'rubygems'
gem 'uuid', '~> 1.0.4"
require 'uuid'

The example '~> 1.0.4' will be true for all 1.0.x versions where x >=
4, but false for all 1.1 or higher versions (this is the "Pessimistic
Version Constraint" described at http://docs.rubygems.org/read/chapter...
if you want more).

-Rob


Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com