Class: UUID

Class | UUID
In: | lib/uuidtools/version.rb lib/uuidtools.rb
Parent: | Object

# uuidtools.rb

     UUIDTools was designed to be a simple library for generating any
     of the various types of UUIDs.  It conforms to RFC 4122 whenever
     possible.

## Example

      UUID.md5_create(UUID_DNS_NAMESPACE, "www.widgets.com")
      => #<UUID:0x287576 UUID:3d813cbb-47fb-32ba-91df-831e1593ac29>
      UUID.sha1_create(UUID_DNS_NAMESPACE, "www.widgets.com")
      => #<UUID:0x2a0116 UUID:21f7f8de-8051-5b89-8680-0195ef798b6a>
      UUID.timestamp_create
      => #<UUID:0x2adfdc UUID:64a5189c-25b3-11da-a97b-00c04fd430c8>
      UUID.random_create
      => #<UUID:0x19013a UUID:984265dc-4200-4f02-ae70-fe4f48964159>

### Methods

<=> eql? get_mac_address hash hexdigest inspect mac_address mac_address= md5_create new nil_uuid? parse parse_raw random_create random_node_id? raw sha1_create timestamp timestamp_create to_i to_s to_uri valid? variant version

### Attributes

clock_seq_hi_and_reserved | [RW] |
clock_seq_low | [RW] |
nodes | [RW] |
time_hi_and_version | [RW] |
time_low | [RW] |
time_mid | [RW] |

### Public Class methods

mac_address=(new_mac_address)

Allows users to set the MAC address manually in cases where the MAC address cannot be obtained programatically.

md5_create(namespace, name)

Creates a UUID using the MD5 hash. (Version 3)

new(time_low, time_mid, time_hi_and_version, clock_seq_hi_and_reserved, clock_seq_low, nodes)
parse(uuid_string)

Parses a UUID from a string.

parse_raw(raw_string)

Parses a UUID from a raw byte string.

random_create()

Creates a UUID from a random value.

sha1_create(namespace, name)

Creates a UUID using the SHA1 hash. (Version 5)

timestamp_create(timestamp=nil)

Creates a UUID from a timestamp.

### Public Instance methods

<=>(other_uuid)

Compares two UUIDs lexically

eql?(other)

Returns true if this UUID is exactly equal to the other UUID.

get_mac_address()

Alias for mac_address

hash()

Returns an integer hash value.

hexdigest()

Returns the hex digest of the UUID object.

inspect()

Returns a representation of the object‘s state

mac_address()

Returns the IEEE 802 address used to generate this UUID or nil if a MAC address was not used.

nil_uuid?()

Returns true if this UUID is the nil UUID (00000000-0000-0000-0000-000000000000).

random_node_id?()

This method applies only to version 1 UUIDs. Checks if the node ID was generated from a random number or from an IEEE 802 address (MAC address). Always returns false for UUIDs that aren‘t version 1. This should not be confused with version 4 UUIDs where more than just the node id is random.

raw()

Returns the raw bytes that represent this UUID.

timestamp()

Returns the timestamp used to generate this UUID

to_i()

Returns an integer representation for this UUID.

to_s()

Returns a string representation for this UUID.

to_uri()

Returns a URI string for this UUID.

valid?()

Returns true if this UUID is valid.

variant()

Returns the UUID variant. Possible values: 0b000 - Reserved, NCS backward compatibility. 0b100 - The variant specified in this document. 0b110 - Reserved, Microsoft Corporation backward compatibility. 0b111 - Reserved for future definition.

version()

Returns the UUID version type. Possible values: 1 - Time-based with unique or random host identifier 2 - DCE Security version (with POSIX UIDs) 3 - Name-based (MD5 hash) 4 - Random 5 - Name-based (SHA-1 hash)

[Validate]