for VT_CLSID Unlike most of the other conversions, the Guid's are serialized/deserialized by actually doing nothing! (eg, _load & _dump are null ops) Rather, its just a string with a different inspect string, and it includes a helper method for creating a Guid from that readable form (format).
# File lib/ole/types/base.rb, line 145 def self.dump guid return 0.chr * SIZE unless guid # allow use of plain strings in place of guids. guid['-'] ? parse(guid) : guid end
# File lib/ole/types/base.rb, line 141 def self.load str new str.to_s end
# File lib/ole/types/base.rb, line 151 def self.parse str vals = str.scan(%r[a-f\d]+/).map(&:hex) if vals.length == 5 # this is pretty ugly vals[3] = ('%04x' % vals[3]).scan(%r../).map(&:hex) vals[4] = ('%012x' % vals[4]).scan(%r../).map(&:hex) guid = new vals.flatten.pack(PACK) return guid if guid.format.delete('{}') == str.downcase.delete('{}') end raise ArgumentError, 'invalid guid - %p' % str end
# File lib/ole/types/base.rb, line 163 def format "%08x-%04x-%04x-%02x%02x-#{'%02x' * 6}" % unpack(PACK) end
# File lib/ole/types/base.rb, line 167 def inspect "#<#{self.class}:{#{format}}>" end