Class: Ole::Types::PropertySet::Section
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.
47
48
49
50
51
52
53
|
# File 'lib/ole/property_set.rb', line 47
def initialize str, property_set
@property_set = property_set
super(*str.unpack(PACK))
self.guid = Clsid.load guid
@map = DATA[guid] ? DATA[guid][1] : nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
89
90
91
92
93
94
95
|
# File 'lib/ole/property_set.rb', line 89
def method_missing name, *args
if args.empty? and @map and @map.values.include? name.to_s
self[name.to_s]
else
super
end
end
|
Instance Attribute Details
#guid ⇒ Object
Returns the value of attribute guid
39
40
41
|
# File 'lib/ole/property_set.rb', line 39
def guid
@guid
end
|
#length ⇒ Object
Returns the value of attribute length.
46
47
48
|
# File 'lib/ole/property_set.rb', line 46
def length
@length
end
|
#offset ⇒ Object
Returns the value of attribute offset
39
40
41
|
# File 'lib/ole/property_set.rb', line 39
def offset
@offset
end
|
Instance Method Details
#[](key) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/ole/property_set.rb', line 81
def [] key
unless Integer === key
return unless @map and key = @map.invert[key]
end
return unless result = properties.assoc(key)
result.last
end
|
#each ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/ole/property_set.rb', line 64
def each
io.seek offset + 8
io.read(length * 8).scan(/.{8}/m).each do |str|
id, property_offset = str.unpack 'V2'
io.seek offset + property_offset
type, value = io.read(8).unpack('V2')
case type
when VT_LPSTR, VT_LPWSTR
value = Variant.load type, io.read(value)
end
yield id, type, value
end
self
end
|
#io ⇒ Object
55
56
57
|
# File 'lib/ole/property_set.rb', line 55
def io
@property_set.io
end
|
59
60
61
62
|
# File 'lib/ole/property_set.rb', line 59
def
io.seek offset
@byte_size, @length = io.read(8).unpack 'V2'
end
|
#properties ⇒ Object
97
98
99
|
# File 'lib/ole/property_set.rb', line 97
def properties
@properties ||= to_enum.to_a
end
|