Class Ole::Types::Section
In: lib/ole/types/property_set.rb
Parent: Object
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

Methods

[]   []=   each   each_raw   io   load_header   new   read_property  

Included Modules

Variant::Constants Enumerable

Constants

SIZE = Clsid::SIZE + 4
PACK = "a#{Clsid::SIZE}v"

Attributes

guid  [RW] 
length  [R] 
offset  [RW] 

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

    # 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

[Source]

    # File lib/ole/types/property_set.rb, line 74
74:                                 def []= key, value
75:                                         raise NotImplementedError, 'section writes not yet implemented'
76:                                 end

[Source]

    # 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

[Source]

    # File lib/ole/types/property_set.rb, line 58
58:                                 def io
59:                                         @property_set.io
60:                                 end

[Source]

    # 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

Private Instance methods

[Source]

    # 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

[Source]

     # 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

[Validate]