Sha256: 3744d8c15c7f999d82164ddbd008530645995f982f72e7f5b78c853ac3df13ff
Contents?: true
Size: 636 Bytes
Versions: 11
Compression:
Stored size: 636 Bytes
Contents
module Skylight module Util class UUID BYTE_SIZE = 16 PREFIX_SIZE = 8 def self.gen(prefix = nil) if prefix == nil return SecureRandom.random_bytes(BYTE_SIZE) end if prefix.bytesize > PREFIX_SIZE raise "UUID prefix must be less than 8 bytes" end # Does not fully conform with the spec rnd = SecureRandom.random_bytes(BYTE_SIZE - prefix.bytesize) new "#{prefix}#{rnd}" end attr_reader :bytes def initialize(bytes) @bytes = bytes end def to_s @to_s ||= "" end end end end
Version data entries
11 entries across 11 versions & 1 rubygems