| Class | Ole::Types::Section |
| In: |
lib/ole/types/property_set.rb
|
| Parent: | Object |
| SIZE | = | Clsid::SIZE + 4 |
| PACK | = | "a#{Clsid::SIZE}v" |
| guid | [RW] | |
| length | [R] | |
| offset | [RW] |
# File lib/ole/types/property_set.rb, line 51
51: def initialize str, property_set
52: @property_set = property_set
53: @guid, @offset = str.unpack PACK
54: self.guid = Clsid.load guid
55: load_header
56: end
# File lib/ole/types/property_set.rb, line 67
67: def [] key
68: each_raw do |id, property_offset|
69: return read_property(property_offset).last if key == id
70: end
71: nil
72: end
# File lib/ole/types/property_set.rb, line 74
74: def []= key, value
75: raise NotImplementedError, 'section writes not yet implemented'
76: end
# File lib/ole/types/property_set.rb, line 78
78: def each
79: each_raw do |id, property_offset|
80: yield id, read_property(property_offset).last
81: end
82: end
# File lib/ole/types/property_set.rb, line 62
62: def load_header
63: io.seek offset
64: @byte_size, @length = io.read(8).unpack 'V2'
65: end
# File lib/ole/types/property_set.rb, line 86
86: def each_raw
87: io.seek offset + 8
88: io.read(length * 8).each_chunk(8) { |str| yield(*str.unpack('V2')) }
89: end
# File lib/ole/types/property_set.rb, line 91
91: def read_property property_offset
92: io.seek offset + property_offset
93: type, value = io.read(8).unpack('V2')
94: # is the method of serialization here custom?
95: case type
96: when VT_LPSTR, VT_LPWSTR
97: value = Variant.load type, io.read(value)
98: # ....
99: end
100: [type, value]
101: end