Class: Ole::Types::PropertySet::Section

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Variant::Constants
Defined in:
lib/ole/types/property_set.rb

Constant Summary collapse

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

Constants included from Variant::Constants

Variant::Constants::VT_TYPEMASK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#group_by, #sum

Constructor Details

#initialize(str, property_set) ⇒ Section

Returns a new instance of Section.



87
88
89
90
91
92
# File 'lib/ole/types/property_set.rb', line 87

def initialize str, property_set
	@property_set = property_set
	@guid, @offset = str.unpack PACK
	self.guid = Clsid.load guid
	load_header
end

Instance Attribute Details

#guidObject

Returns the value of attribute guid.



84
85
86
# File 'lib/ole/types/property_set.rb', line 84

def guid
  @guid
end

#lengthObject (readonly)

Returns the value of attribute length.



85
86
87
# File 'lib/ole/types/property_set.rb', line 85

def length
  @length
end

#offsetObject

Returns the value of attribute offset.



84
85
86
# File 'lib/ole/types/property_set.rb', line 84

def offset
  @offset
end

Instance Method Details

#[](key) ⇒ Object



103
104
105
106
107
108
# File 'lib/ole/types/property_set.rb', line 103

def [] key
	each_raw do |id, property_offset|
		return read_property(property_offset).last if key == id
	end
	nil
end

#[]=(key, value) ⇒ Object

Raises:

  • (NotImplementedError)


110
111
112
# File 'lib/ole/types/property_set.rb', line 110

def []= key, value
	raise NotImplementedError, 'section writes not yet implemented'
end

#eachObject



114
115
116
117
118
# File 'lib/ole/types/property_set.rb', line 114

def each
	each_raw do |id, property_offset|
		yield id, read_property(property_offset).last
	end
end

#ioObject



94
95
96
# File 'lib/ole/types/property_set.rb', line 94

def io
	@property_set.io
end

#load_headerObject



98
99
100
101
# File 'lib/ole/types/property_set.rb', line 98

def load_header
	io.seek offset
	@byte_size, @length = io.read(8).unpack 'V2'
end