Class: Mapi::Pst::Index
- Inherits:
-
Struct
- Object
- Struct
- Mapi::Pst::Index
- Defined in:
- lib/mapi/pst.rb
Overview
pst_index
Direct Known Subclasses
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
-
#id ⇒ Object
Returns the value of attribute id.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#pst ⇒ Object
Returns the value of attribute pst.
-
#size ⇒ Object
Returns the value of attribute size.
-
#u1 ⇒ Object
Returns the value of attribute u1.
Instance Method Summary collapse
- #data? ⇒ Boolean
-
#initialize(data) ⇒ Index
constructor
A new instance of Index.
-
#inspect ⇒ Object
show all numbers in hex.
- #read(decrypt = true) ⇒ Object
- #type ⇒ Object
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
#id ⇒ Object
Returns the value of attribute id
353 354 355 |
# File 'lib/mapi/pst.rb', line 353 def id @id end |
#offset ⇒ Object
Returns the value of attribute offset
353 354 355 |
# File 'lib/mapi/pst.rb', line 353 def offset @offset end |
#pst ⇒ Object
Returns the value of attribute pst.
359 360 361 |
# File 'lib/mapi/pst.rb', line 359 def pst @pst end |
#size ⇒ Object
Returns the value of attribute size
353 354 355 |
# File 'lib/mapi/pst.rb', line 353 def size @size end |
#u1 ⇒ Object
Returns the value of attribute u1
353 354 355 |
# File 'lib/mapi/pst.rb', line 353 def u1 @u1 end |
Instance Method Details
#data? ⇒ Boolean
384 385 386 |
# File 'lib/mapi/pst.rb', line 384 def data? (id & 0x2) == 0 end |
#inspect ⇒ Object
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 |
#type ⇒ Object
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 |