| Module | Ole::Types |
| In: |
lib/ole/types/property_set.rb
lib/ole/types/base.rb |
The Types module contains all the serialization and deserialization code for standard ole types.
It also defines all the variant type constants, and symbolic names.
| FROM_UTF16 | = | Lpwstr::FROM_UTF16 |
| TO_UTF16 | = | Lpwstr::TO_UTF16 |
| guid | [R] | |
| io | [R] | |
| os | [R] | |
| sections | [R] | |
| signature | [R] | |
| unknown | [R] |
# File lib/ole/types/base.rb, line 243
243: def self.load_time str
244: Variant.load VT_FILETIME, str
245: end
# File lib/ole/types/property_set.rb, line 106
106: def initialize io
107: @io = io
108: load_header io.read(HEADER_SIZE)
109: load_section_list io.read(@num_sections * Section::SIZE)
110: # expect no gap between last section and start of data.
111: #Log.warn "gap between section list and property data" unless io.pos == @sections.map(&:offset).min
112: end
# File lib/ole/types/property_set.rb, line 125
125: def [] key
126: pair = PROPERTY_MAP[key.to_s] or return nil
127: section = @sections.find { |s| s.guid == pair.first } or return nil
128: section[pair.last]
129: end
# File lib/ole/types/property_set.rb, line 131
131: def []= key, value
132: pair = PROPERTY_MAP[key.to_s] or return nil
133: section = @sections.find { |s| s.guid == pair.first } or return nil
134: section[pair.last] = value
135: end
# File lib/ole/types/property_set.rb, line 149
149: def each
150: @sections.each do |section|
151: next unless pair = DATA[section.guid]
152: map = pair.last
153: section.each do |id, value|
154: name = map[id] or next
155: yield name, value
156: end
157: end
158: end
# File lib/ole/types/property_set.rb, line 114
114: def load_header str
115: @signature, @unknown, @os_id, @guid, @num_sections = str.unpack HEADER_PACK
116: # should i check that unknown == 0? it usually is. so is the guid actually
117: @guid = Clsid.load @guid
118: @os = OS_MAP[@os_id] || Log.warn("unknown operating system id #{@os_id}")
119: end
# File lib/ole/types/property_set.rb, line 121
121: def load_section_list str
122: @sections = str.to_enum(:each_chunk, Section::SIZE).map { |s| Section.new s, self }
123: end
# File lib/ole/types/property_set.rb, line 137
137: def method_missing name, *args, &block
138: if name.to_s =~ /(.*)=$/
139: return super unless args.length == 1
140: return super unless PROPERTY_MAP[$1]
141: self[$1] = args.first
142: else
143: return super unless args.length == 0
144: return super unless PROPERTY_MAP[name.to_s]
145: self[name]
146: end
147: end