class Ole::Types::PropertySet::Section

Constants

PACK
SIZE

Attributes

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

Public Class Methods

new(str, property_set) click to toggle source
# File lib/ole/types/property_set.rb, line 51
def initialize str, property_set
  @property_set = property_set
  @guid, @offset = str.unpack PACK
  self.guid = Clsid.load guid
  load_header
end

Public Instance Methods

[](key) click to toggle source
# File lib/ole/types/property_set.rb, line 67
def [] key
  each_raw do |id, property_offset|
    return read_property(property_offset).last if key == id
  end
  nil
end
[]=(key, value) click to toggle source
# File lib/ole/types/property_set.rb, line 74
def []= key, value
  raise NotImplementedError, 'section writes not yet implemented'
end
each() { |id, read_property(property_offset).last| ... } click to toggle source
# File lib/ole/types/property_set.rb, line 78
def each
  each_raw do |id, property_offset|
    yield id, read_property(property_offset).last
  end
end
io() click to toggle source
# File lib/ole/types/property_set.rb, line 58
def io
  @property_set.io
end
load_header() click to toggle source
# File lib/ole/types/property_set.rb, line 62
def load_header
  io.seek offset
  @byte_size, @length = io.read(8).unpack 'V2'
end

Private Instance Methods

each_raw() { |*unpack('V2')| ... } click to toggle source
# File lib/ole/types/property_set.rb, line 86
def each_raw
  io.seek offset + 8
  io.read(length * 8).each_chunk(8) { |str| yield(*str.unpack('V2')) }
end
read_property(property_offset) click to toggle source
# File lib/ole/types/property_set.rb, line 91
def read_property property_offset
  io.seek offset + property_offset
  type, value = io.read(8).unpack('V2')
  # is the method of serialization here custom?
  case type
  when VT_LPSTR, VT_LPWSTR
    value = Variant.load type, io.read(value)
  # ....
  end
  [type, value]
end