Represents a UUID (Universally Unique IDentifier).
Generates UUID from bytes, applying version and variant to the UUID if present.
Creates UUID from 16-bytes slice.
Creates another UUID which is a copy of uuid, but allows overriding variant or version.
Creates new UUID by decoding value string from hyphenated (ie.
Creates UUID from JSON using JSON::PullParser.
Generates RFC 4122 v4 UUID.
Returns true if other UUID represents the same UUID, false otherwise.
Returns the binary representation of the UUID.
Convert to String in literal format.
Returns UUID as JSON value.
Same as #inspect(io).
Returns unsafe pointer to 16-bytes.
Returns true if UUID is a V1, raises Error otherwise.
Returns true if UUID is a V1, false otherwise.
Returns true if UUID is a V2, raises Error otherwise.
Returns true if UUID is a V2, false otherwise.
Returns true if UUID is a V3, raises Error otherwise.
Returns true if UUID is a V3, false otherwise.
Returns true if UUID is a V4, raises Error otherwise.
Returns true if UUID is a V4, false otherwise.
Returns true if UUID is a V5, raises Error otherwise.
Returns true if UUID is a V5, false otherwise.
Returns UUID variant.
Returns version based on RFC4122 format.
Struct
Value
Object
Object
Generates UUID from bytes, applying version and variant to the UUID if present.
Creates UUID from 16-bytes slice. Raises if slice isn't 16 bytes long. See #initialize for variant and version.
Creates another UUID which is a copy of uuid, but allows overriding variant or version.
Creates new UUID by decoding value string from hyphenated (ie. ba714f86-cac6-42c7-8956-bcf5105e1b81), hexstring (ie. 89370a4ab66440c8add39e06f2bb6af6) or URN (ie. urn:uuid:3f9eaf9e-cdb0-45cc-8ecb-0e5b2bfb0c20) format.
Creates UUID from JSON using JSON::PullParser.
NOTE require "uuid/json" is required to opt-in to this feature.
require "json"
require "uuid"
require "uuid/json"
class Example
include JSON::Serializable
property id : UUID
end
example = Example.from_json(%({"id": "ba714f86-cac6-42c7-8956-bcf5105e1b81"}))
example.id # => UUID(ba714f86-cac6-42c7-8956-bcf5105e1b81) Generates RFC 4122 v4 UUID.
It is strongly recommended to use a cryptographically random source for random, such as Random::Secure.
Returns the binary representation of the UUID.
Returns UUID as JSON value.
NOTE require "uuid/json" is required to opt-in to this feature.
uuid = UUID.new("87b3042b-9b9a-41b7-8b15-a93d3f17025e")
uuid.to_json # => "\"87b3042b-9b9a-41b7-8b15-a93d3f17025e\"" Same as #inspect(io).
Returns unsafe pointer to 16-bytes.
Returns true if UUID is a V1, false otherwise.
Returns true if UUID is a V2, false otherwise.
Returns true if UUID is a V3, false otherwise.
Returns true if UUID is a V4, false otherwise.
Returns true if UUID is a V5, false otherwise.
Returns UUID variant.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/UUID.html