Class: Ole::Types::Clsid

### Home Classes Methods

### In Files

- lib/ole/types/base.rb

### Parent

String

### Methods

- ::dump
- ::load
- ::parse
- #format
- #inspect

### 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::Clsid

for VT_CLSID Unlike most of the other conversions, the Guid's are serialized/deserialized by actually doing nothing! (eg, _load & _dump are null ops) Rather, its just a string with a different inspect string, and it includes a helper method for creating a Guid from that readable form (format).

### Constants

PACK
SIZE

### Public Class Methods

dump(guid) click to toggle source

    # File lib/ole/types/base.rb, line 175
    def self.dump guid
      return 0.chr * SIZE unless guid
      # allow use of plain strings in place of guids.
      guid['-'] ? parse(guid) : guid
    end

load(str) click to toggle source

    # File lib/ole/types/base.rb, line 171
    def self.load str
      new str.to_s
    end

parse(str) click to toggle source

    # File lib/ole/types/base.rb, line 181
    def self.parse str
      vals = str.scan(/[a-f\d]+/).map(&:hex)
      if vals.length == 5
        # this is pretty ugly
        vals[3] = ('%04x' % vals[3]).scan(/../).map(&:hex)
        vals[4] = ('%012x' % vals[4]).scan(/../).map(&:hex)
        guid = new vals.flatten.pack(PACK)
        return guid if guid.format.delete('{}') == str.downcase.delete('{}')
      end
      raise ArgumentError, 'invalid guid - %p' % str
    end

### Public Instance Methods

format() click to toggle source

    # File lib/ole/types/base.rb, line 193
    def format
      "%08x-%04x-%04x-%02x%02x-#{'%02x' * 6}" % unpack(PACK)
    end

inspect() click to toggle source

    # File lib/ole/types/base.rb, line 197
    def inspect
      "#<#{self.class}:{#{format}}>"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.