Sha256: 9077a4a81314339823e31adb6e029f19b934cfa1e04bb83dd454101f59db71cf
Contents?: true
Size: 722 Bytes
Versions: 21
Compression:
Stored size: 722 Bytes
Contents
require 'uuidtools' class UUID # # A string suitable for using as a path name -- # # Ex. # urn:uuid:3c0dce44-80a8-11dd-a897-001ff35a0a8b => # urn_uuid/3c0dce44/80a8/11dd/a897/001ff35a0a8b # # It's well possible there are more perspicacious choices for points to split # the string, but until we hit that limit this'll do. # def to_path 'urn_uuid/' + to_s.gsub(/[\:\-]/,'/') end def self.hex_to_str str /([\da-f]{8})([\da-f]{4})([\da-f]{4})([\da-f]{4})([\da-f]{12})/.match(str).captures.join '-' end def self.parse_hex str parse(UUID.hex_to_str(str)) end # Overrides UUIDTools -- force 32 hex digits (leading zeros) def hexdigest "%032x" % self.to_i end end
Version data entries
21 entries across 21 versions & 1 rubygems