Class Ole::Types::Clsid
In: lib/ole/types/base.rb
Parent: String
String Data Lpstr Clsid Lpwstr Section Enumerable DateTime FileTime Constants Variant::Constants Storage\n[lib/ole/storage/base.rb\nlib/ole/storage/file_system.rb\nlib/ole/storage/meta_data.rb] PropertySet lib/ole/storage/file_system.rb lib/ole/types/property_set.rb lib/ole/types/base.rb Constants Constants Variant Types Ole dot/m_9_0.png

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).

Methods

dump   format   inspect   load   parse  

Constants

SIZE = 16
PACK = 'V v v CC C6'

Public Class methods

[Source]

     # 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

[Source]

     # File lib/ole/types/base.rb, line 109
109:                         def self.load str
110:                                 new str.to_s
111:                         end

[Source]

     # 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

Public Instance methods

[Source]

     # File lib/ole/types/base.rb, line 131
131:                         def format
132:                                 "%08x-%04x-%04x-%02x%02x-#{'%02x' * 6}" % unpack(PACK)
133:                         end

[Source]

     # File lib/ole/types/base.rb, line 135
135:                         def inspect
136:                                 "#<#{self.class}:{#{format}}>"
137:                         end

[Validate]