class GnUUID::UUID

handles UUID byte string and it's conversion to different format NOTE: this is a general UUID class which is not limited to only v5

Attributes

bytes[R]

Public Class Methods

new(bytes) click to toggle source
# File lib/gn_uuid/uuid.rb, line 9
def initialize(bytes)
  @bytes = bytes
  @ary = @bytes.unpack("C*")
end

Public Instance Methods

inspect()
Alias for: to_uri
to_i() click to toggle source
# File lib/gn_uuid/uuid.rb, line 21
def to_i
  @to_i ||= @ary.inject(0) { |a, e| a << 8 | e }
end
to_s() click to toggle source
# File lib/gn_uuid/uuid.rb, line 14
def to_s
  return @str if @str
  fmt = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
        "%02x%02x%02x%02x%02x%02x"
  @str = fmt % @ary
end
to_uri() click to toggle source
# File lib/gn_uuid/uuid.rb, line 25
def to_uri
  "urn:uuid:" + to_s
end
Also aliased as: inspect
version() click to toggle source
# File lib/gn_uuid/uuid.rb, line 31
def version
  @ary[6] >> 4
end