class UUIDv6::Sequence
Usage:
seq = UUIDv6::Sequence.new uid = seq.call => "137ab4b3-3748-6090-80e3-0c859007c113"
Attributes
uuid_v1[R]
Public Class Methods
new()
click to toggle source
# File lib/uuid_v6/sequence.rb, line 13 def initialize @uuid_v1 = ::UUID.new end
Public Instance Methods
call(uuid = uuid_v1.generate)
click to toggle source
@param uuid [String] UUID version 1 (tools.ietf.org/html/rfc4122)
# File lib/uuid_v6/sequence.rb, line 18 def call(uuid = uuid_v1.generate) uh = uuid.tr('-', '') tlo1 = uh[0...5] tlo2 = uh[5...8] tmid = uh[8...12] thig = uh[13...16] rest = uh[16...] uh6 = thig + tmid + tlo1 + '6' + tlo2 + rest to_uuid(uh6) end
Private Instance Methods
to_uuid(str)
click to toggle source
# File lib/uuid_v6/sequence.rb, line 31 def to_uuid(str) [str[0..7], str[8..11], str[12..15], str[16..19], str[20..]].join('-') end