Module Ole::Types
In: lib/ole/types/property_set.rb
lib/ole/types/base.rb
String Data Lpstr Clsid Lpwstr Section Enumerable DateTime FileTime Constants Variant::Constants Storage\n[lib/ole/storage/base.rb\nlib/ole/storage/file_system.rb\nlib/ole/storage/meta_data.rb] PropertySet lib/ole/storage/file_system.rb lib/ole/types/property_set.rb lib/ole/types/base.rb Constants Constants Variant Types Ole dot/m_9_0.png

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.

Methods

[]   []=   each   load_guid   load_header   load_section_list   load_time   method_missing   new   to_h  

Included Modules

Constants Enumerable Variant::Constants

Classes and Modules

Module Ole::Types::Constants
Module Ole::Types::Variant
Class Ole::Types::Clsid
Class Ole::Types::Data
Class Ole::Types::FileTime
Class Ole::Types::Lpstr
Class Ole::Types::Lpwstr
Class Ole::Types::PropertySet
Class Ole::Types::Section

Constants

FROM_UTF16 = Lpwstr::FROM_UTF16
TO_UTF16 = Lpwstr::TO_UTF16

Attributes

guid  [R] 
io  [R] 
os  [R] 
sections  [R] 
signature  [R] 
unknown  [R] 

Public Class methods

deprecated aliases, kept mostly for the benefit of ruby-msg, until i release a new version.

[Source]

     # File lib/ole/types/base.rb, line 239
239:                 def self.load_guid str
240:                         Variant.load VT_CLSID, str
241:                 end

[Source]

     # File lib/ole/types/base.rb, line 243
243:                 def self.load_time str
244:                         Variant.load VT_FILETIME, str
245:                 end

[Source]

     # 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

Public Instance methods

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # File lib/ole/types/property_set.rb, line 160
160:                         def to_h
161:                                 inject({}) { |hash, (name, value)| hash.update name.to_sym => value }
162:                         end

[Validate]