Class: Mapi::Pst::Index

Inherits:
Struct
  • Object
show all
Defined in:
lib/mapi/pst.rb

Overview

pst_index

Direct Known Subclasses

Index64

Constant Summary collapse

UNPACK_STR =
'VVvv'
SIZE =
12
BLOCK_SIZE =

index blocks was 516 but bogus

512
COUNT_MAX =

max active items (ITEM_COUNT_OFFSET / Index::SIZE = 41)

41

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Index

Returns a new instance of Index.



360
361
362
363
# File 'lib/mapi/pst.rb', line 360

def initialize data
	data = Pst.unpack data, UNPACK_STR if String === data
	super(*data)
end

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



353
354
355
# File 'lib/mapi/pst.rb', line 353

def id
  @id
end

#offsetObject

Returns the value of attribute offset

Returns:

  • (Object)

    the current value of offset



353
354
355
# File 'lib/mapi/pst.rb', line 353

def offset
  @offset
end

#pstObject

Returns the value of attribute pst.



359
360
361
# File 'lib/mapi/pst.rb', line 359

def pst
  @pst
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



353
354
355
# File 'lib/mapi/pst.rb', line 353

def size
  @size
end

#u1Object

Returns the value of attribute u1

Returns:

  • (Object)

    the current value of u1



353
354
355
# File 'lib/mapi/pst.rb', line 353

def u1
  @u1
end

Instance Method Details

#data?Boolean

Returns:

  • (Boolean)


384
385
386
# File 'lib/mapi/pst.rb', line 384

def data?
	(id & 0x2) == 0
end

#inspectObject

show all numbers in hex



395
396
397
# File 'lib/mapi/pst.rb', line 395

def inspect
	super.gsub(/=(\d+)/) { '=0x%x' % $1.to_i }.sub(/Index /, "Index type=#{type.inspect}, ")
end

#read(decrypt = true) ⇒ Object



388
389
390
391
392
# File 'lib/mapi/pst.rb', line 388

def read decrypt=true
	# only data blocks are every encrypted
	decrypt = false unless data?
	pst.pst_read_block_size offset, size, decrypt
end

#typeObject



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/mapi/pst.rb', line 365

def type
	@type ||= begin
		if id & 0x2 == 0
			:data
		else
			first_byte, second_byte = read.unpack('CC')
			if first_byte == 1
				raise second_byte unless second_byte == 1
				:data_chain_header
			elsif first_byte == 2
				raise second_byte unless second_byte == 0
				:id2_assoc
			else
				raise FormatError, 'unknown first byte for block - %p' % first_byte
			end
		end
	end
end