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"

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.



51
52
53
54
55
56
# 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

Instance Attribute Details

#guidObject

Returns the value of attribute guid.



48
49
50
# File 'lib/ole/types/property_set.rb', line 48

def guid
  @guid
end

#lengthObject (readonly)

Returns the value of attribute length.



49
50
51
# File 'lib/ole/types/property_set.rb', line 49

def length
  @length
end

#offsetObject

Returns the value of attribute offset.



48
49
50
# File 'lib/ole/types/property_set.rb', line 48

def offset
  @offset
end

Instance Method Details

#[](key) ⇒ Object



67
68
69
70
71
72
# 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) ⇒ Object

Raises:

  • (NotImplementedError)


74
75
76
# File 'lib/ole/types/property_set.rb', line 74

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

#eachObject



78
79
80
81
82
# 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

#ioObject



58
59
60
# File 'lib/ole/types/property_set.rb', line 58

def io
	@property_set.io
end

#load_headerObject



62
63
64
65
# File 'lib/ole/types/property_set.rb', line 62

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