From 15169a69df6303f260d2a8e90531783ee7870420 Mon Sep 17 00:00:00 2001 From: Jack Thorne Date: Tue, 4 Jan 2022 01:22:59 -0600 Subject: [PATCH 1/2] adds docs for UUID#urn --- src/uuid.cr | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/uuid.cr b/src/uuid.cr index 994813477a03..68bcb1e167a8 100644 --- a/src/uuid.cr +++ b/src/uuid.cr @@ -202,6 +202,16 @@ struct UUID @bytes.to_slice.hexstring end + # Returns a `String` that is a valid urn of *self* + # + # ``` + # require "uuid" + # + # uuid = UUID.empty + # uuid.urn # => "urn:uuid:00000000-0000-4000-0000-000000000000" + # uuid2 = UUID.random + # uuid2 # => "urn:uuid:c49fc136-9362-4414-81a5-9a7e0fcca0f1" + # ``` def urn : String String.build(45) do |str| str << "urn:uuid:" From 80420c0421ff7f28622d2db024e914ab4729fa76 Mon Sep 17 00:00:00 2001 From: Jack Thorne Date: Tue, 4 Jan 2022 12:24:04 -0600 Subject: [PATCH 2/2] update docs --- src/uuid.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uuid.cr b/src/uuid.cr index 68bcb1e167a8..bfb81e1677b4 100644 --- a/src/uuid.cr +++ b/src/uuid.cr @@ -209,8 +209,8 @@ struct UUID # # uuid = UUID.empty # uuid.urn # => "urn:uuid:00000000-0000-4000-0000-000000000000" - # uuid2 = UUID.random - # uuid2 # => "urn:uuid:c49fc136-9362-4414-81a5-9a7e0fcca0f1" + # uuid2 = UUID.new("c49fc136-9362-4414-81a5-9a7e0fcca0f1") + # uuid2.urn # => "urn:uuid:c49fc136-9362-4414-81a5-9a7e0fcca0f1" # ``` def urn : String String.build(45) do |str|