Class JSON::Util::UUID
In: lib/json-schema/uri/uuid.rb
Parent: Object

Methods

<=>   ==   create   create_md5   create_random   create_sha1   guid   pack   parse   to_i   to_int   to_s   to_uri   unpack   urn   version  

Included Modules

Comparable

Constants

STATE_FILE = 'ruby-uuid'
NameSpace_DNS = parse "6ba7b810-9dad-11d1-80b4-00c04fd430c8"   Pre-defined UUID Namespaces described in RFC4122 Appendix C.
NameSpace_URL = parse "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
NameSpace_OID = parse "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
NameSpace_X500 = parse "6ba7b814-9dad-11d1-80b4-00c04fd430c8"
Nil = parse "00000000-0000-0000-0000-000000000000"   The Nil UUID in RFC4122 Section 4.1.7

External Aliases

create_sha1 -> create_v5
create_md5 -> create_v3
create_random -> create_v4
create -> create_v1

Public Class methods

create the "version 1" UUID with current system clock, current UTC timestamp, and the IEEE 802 address (so-called MAC address).

Speed notice: it‘s slow. It writes some data into hard drive on every invokation. If you want to speed this up, try remounting tmpdir with a memory based filesystem (such as tmpfs). STILL slow? then no way but rewrite it with c :)

UUID generation using MD5 (for backward compat.)

UUID generation using random-number generator. From it‘s random nature, there‘s no warranty that the created ID is really universaly unique.

UUID generation using SHA1. Recommended over create_md5. Namespace object is another UUID, some of them are pre-defined below.

The ‘primitive constructor’ of this class Note UUID.pack(uuid.unpack) == uuid

A simple GUID parser: just ignores unknown characters and convert hexadecimal dump into 16-octet object.

Public Instance methods

UUIDs are comparable (don‘t know what benefits are there, though).

Two UUIDs are said to be equal if and only if their (byte-order canonicalized) integer representations are equivallent. Refer RFC4122 for details.

guid()

Alias for to_s

to_i()

Alias for to_int

Convert into 128-bit unsigned integer Typically a Bignum instance, but can be a Fixnum.

Generate the string representation (a.k.a GUID) of this UUID

Convert into a RFC4122-comforming URN representation

The ‘primitive deconstructor’, or the dual to pack. Note UUID.pack(uuid.unpack) == uuid

urn()

Alias for to_uri

Gets the version of this UUID returns nil if bad version

[Validate]