module Thrift::UUID
Constants
- UUID_REGEX
Public Class Methods
Source
# File lib/thrift/uuid.rb 37 def self.uuid_bytes(uuid) 38 [uuid.delete("-")].pack("H*") 39 end
Source
# File lib/thrift/uuid.rb 41 def self.uuid_from_bytes(bytes) 42 unless bytes.bytesize == 16 43 raise ProtocolException.new(ProtocolException::INVALID_DATA, "Invalid UUID data length") 44 end 45 46 hex = bytes.unpack1("H*") 47 "#{hex[0, 8]}-#{hex[8, 4]}-#{hex[12, 4]}-#{hex[16, 4]}-#{hex[20, 12]}" 48 end
Source
# File lib/thrift/uuid.rb 27 def self.validate_uuid!(uuid) 28 unless uuid.is_a?(String) 29 raise ProtocolException.new(ProtocolException::INVALID_DATA, "UUID must be a string") 30 end 31 32 unless UUID_REGEX.match?(uuid) 33 raise ProtocolException.new(ProtocolException::INVALID_DATA, "Invalid UUID format") 34 end 35 end