Class: Ole::Types::PropertySet

### Home Classes Methods

### In Files

- lib/ole/types/property_set.rb

### Parent

Object

### Namespace

- MODULE Ole::Types::PropertySet::Constants
- CLASS Ole::Types::PropertySet::Section

### Methods

- ::new
- #[]
- #[]=
- #each
- #load_header
- #load_section_list
- #method_missing
- #to_h

### Included Modules

- Ole::Types::PropertySet::Constants

### Files

- ChangeLog
- README

### Class/Module Index

Quicksearch

- Ole
- Ole::IOMode
- Ole::IOMode::Constants
- Ole::Storage
- Ole::Storage::AllocationTable
- Ole::Storage::AllocationTable::Big
- Ole::Storage::AllocationTable::Small
- Ole::Storage::DirClass
- Ole::Storage::DirClass::Dir
- Ole::Storage::Dirent
- Ole::Storage::FileClass
- Ole::Storage::FileClass::Stat
- Ole::Storage::Header
- Ole::Storage::MetaData
- Ole::Storage::RangesIOMigrateable
- Ole::Storage::RangesIOResizeable
- Ole::Types
- Ole::Types::Clsid
- Ole::Types::Data
- Ole::Types::FileTime
- Ole::Types::Lpstr
- Ole::Types::Lpwstr
- Ole::Types::PropertySet
- Ole::Types::PropertySet::Constants
- Ole::Types::PropertySet::Section
- Ole::Types::Variant
- Ole::Types::Variant::Constants
- RangesIO

No matching classes.

# Ole::Types::PropertySet

The PropertySet class currently supports readonly access to the properties serialized in "property set" streams, such as the file "005SummaryInformation", in OLE files.

Think it has its roots in MFC property set serialization.

See poi.apache.org/hpsf/internals.html for details

### Constants

DATA

  define a smattering of the property set guids.

HEADER_PACK
HEADER_SIZE
OS_MAP
PROPERTY_MAP

  create an inverted map of names to guid/key pairs

### Attributes

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

### Public Class Methods

new(io) click to toggle source

    # File lib/ole/types/property_set.rb, line 141
    def initialize io
      @io = io
      load_header io.read(HEADER_SIZE)
      load_section_list io.read(@num_sections * Section::SIZE)
      # expect no gap between last section and start of data.
      #Log.warn "gap between section list and property data" unless io.pos == @sections.map(&:offset).min
    end

### Public Instance Methods

[](key) click to toggle source

    # File lib/ole/types/property_set.rb, line 160
    def [] key
      pair = PROPERTY_MAP[key.to_s] or return nil
      section = @sections.find { |s| s.guid == pair.first } or return nil
      section[pair.last]
    end

[]=(key, value) click to toggle source

    # File lib/ole/types/property_set.rb, line 166
    def []= key, value
      pair = PROPERTY_MAP[key.to_s] or return nil
      section = @sections.find { |s| s.guid == pair.first } or return nil
      section[pair.last] = value
    end

each() click to toggle source

    # File lib/ole/types/property_set.rb, line 184
    def each
      @sections.each do |section|
        next unless pair = DATA[section.guid]
        map = pair.last
        section.each do |id, value|
          name = map[id] or next
          yield name, value
        end
      end
    end

load_header(str) click to toggle source

    # File lib/ole/types/property_set.rb, line 149
    def load_header str
      @signature, @unknown, @os_id, @guid, @num_sections = str.unpack HEADER_PACK
      # should i check that unknown == 0? it usually is. so is the guid actually
      @guid = Clsid.load @guid
      @os = OS_MAP[@os_id] || Log.warn("unknown operating system id #{@os_id}")
    end

load_section_list(str) click to toggle source

    # File lib/ole/types/property_set.rb, line 156
    def load_section_list str
      @sections = str.to_enum(:each_chunk, Section::SIZE).map { |s| Section.new s, self }
    end

method_missing(name, *args, &block) click to toggle source

    # File lib/ole/types/property_set.rb, line 172
    def method_missing name, *args, &block
      if name.to_s =~ /(.*)=$/
        return super unless args.length == 1
        return super unless PROPERTY_MAP[$1]
        self[$1] = args.first
      else
        return super unless args.length == 0
        return super unless PROPERTY_MAP[name.to_s]
        self[name]
      end
    end

to_h() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.