Class | Ole::Types::Clsid |
In: |
lib/ole/types/base.rb
|
Parent: | String |
SIZE | = | 16 |
PACK | = | 'V v v CC C6' |
# File lib/ole/types/base.rb, line 113 113: def self.dump guid 114: return 0.chr * SIZE unless guid 115: # allow use of plain strings in place of guids. 116: guid['-'] ? parse(guid) : guid 117: end
# File lib/ole/types/base.rb, line 119 119: def self.parse str 120: vals = str.scan(/[a-f\d]+/i).map(&:hex) 121: if vals.length == 5 122: # this is pretty ugly 123: vals[3] = ('%04x' % vals[3]).scan(/../).map(&:hex) 124: vals[4] = ('%012x' % vals[4]).scan(/../).map(&:hex) 125: guid = new vals.flatten.pack(PACK) 126: return guid if guid.format.delete('{}') == str.downcase.delete('{}') 127: end 128: raise ArgumentError, 'invalid guid - %p' % str 129: end