struct UUID
- UUID
- Struct
- Value
- Object
Overview
Represents a UUID (Universally Unique IDentifier).
NOTE To use UUID
, you must explicitly import it with require "uuid"
Included Modules
- Comparable(UUID)
Defined in:
uuid_utils.crClass Method Summary
-
.uuid3(ns : UUID | Namespace, value)
Generate a UUID from the MD5 hash of a namespace UUID and a name.
-
.uuid4
Generate a random UUID.
-
.uuid5(ns : UUID | Namespace, value)
Generate a UUID from the SHA-1 hash of a namespace UUID and a name.
Class Method Detail
Generate a UUID from the MD5 hash of a namespace UUID and a name.
Example:
require "uuid_utils"
namespace = UUID.new("68ab717d-d847-4277-be1a-303be8ac3d97")
msg = "Hello World!"
puts UUID.uuid3(namespace, msg) # => 33056d85-5061-31c8-9656-df07f3eec397
def self.uuid4
#
Generate a random UUID.
Example:
require "uuid_utils"
puts UUID.uuid4 # => 39e54402-44c6-42c6-be52-4bb9ab18a5fa
Generate a UUID from the SHA-1 hash of a namespace UUID and a name.
Example:
require "uuid_utils"
namespace = UUID.new("68ab717d-d847-4277-be1a-303be8ac3d97")
msg = "Hello World!"
puts UUID.uuid5(namespace, msg) # => 562ed049-5b55-582d-ba51-812a786927ca