-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
36 lines (24 loc) · 923 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
libuuidrb uses e2fsprogs'[1] libuuid (<uuid/uuid.h>) to generate DCE
compatible universally unique identifiers.
0. prerequesites
$ irb
>> require 'lib_uuid'
1. generating
>> u = LibUUID::UUID.new
=> #<LibUUID::UUID:0x969decc>
>> u.to_guid # => "965555c1-2860-47f5-a3f5-a9c83a3b0b5e"
>> u.to_short_guid # => "llVVwShgR_Wj9anIOjsLXg"
or
>> LibUUID::UUID.guid # => "ca220b11-a974-4c1d-99d1-78c32d997848"
>> LibUUID::UUID.short_guid # => "8fPommPCQ7y1BSh55d7kFw"
2. parsing
>> v = LibUUID::UUID.new(u.to_guid) # => #<LibUUID::UUID:0x9696b2c>
>> w = LibUUID::UUID.new(u.to_short_guid) # => #<LibUUID::UUID:0x9693684>
>> u == v # => true
>> u == w # => true
3. validating
>> LibUUID::UUID.valid? u.to_guid # => true
>> LibUUID::UUID.valid? v.to_short_guid # => true
>> LibUUID::UUID.valid? u.to_guid, v.to_guid, w.to_short_guid # => true
>> LibUUID::UUID.valid? 'foo' # => false
[1] http://e2fsprogs.sourceforge.net/