Class: Cabriolet::Models::OABHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/models/oab_header.rb

Overview

OAB (Outlook Offline Address Book) file header

OAB files come in two variants:

  • Full files (version 3.1)
  • Incremental patches (version 3.2)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_hi:, version_lo:, block_max:, target_size:, source_size: nil, source_crc: nil, target_crc: nil) ⇒ OABHeader

Create new OAB header

Parameters:

  • version_hi (Integer) —

    High version number

  • version_lo (Integer) —

    Low version number (1=full, 2=patch)

  • block_max (Integer) —

    Maximum block size

  • target_size (Integer) —

    Decompressed output size

  • source_size (Integer) (defaults to: nil) —

    Base file size (patches only)

  • source_crc (Integer) (defaults to: nil) —

    Base file CRC (patches only)

  • target_crc (Integer) (defaults to: nil) —

    Target file CRC (patches only)



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cabriolet/models/oab_header.rb', line 23

def initialize(version_hi:, version_lo:, block_max:, target_size:,
               source_size: nil, source_crc: nil, target_crc: nil)
  @version_hi = version_hi
  @version_lo = version_lo
  @block_max = block_max
  @target_size = target_size
  @source_size = source_size
  @source_crc = source_crc
  @target_crc = target_crc
  @is_patch = (version_lo == 2)
end

Instance Attribute Details

#block_max ⇒ Object

Returns the value of attribute block_max.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def block_max
  @block_max
end

#is_patch ⇒ Object

Returns the value of attribute is_patch.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def is_patch
  @is_patch
end

#source_crc ⇒ Object

Returns the value of attribute source_crc.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def source_crc
  @source_crc
end

#source_size ⇒ Object

Returns the value of attribute source_size.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def source_size
  @source_size
end

#target_crc ⇒ Object

Returns the value of attribute target_crc.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def target_crc
  @target_crc
end

#target_size ⇒ Object

Returns the value of attribute target_size.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def target_size
  @target_size
end

#version_hi ⇒ Object

Returns the value of attribute version_hi.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def version_hi
  @version_hi
end

#version_lo ⇒ Object

Returns the value of attribute version_lo.



11
12
13
# File 'lib/cabriolet/models/oab_header.rb', line 11

def version_lo
  @version_lo
end

Instance Method Details

#full? ⇒ Boolean

Check if this is a full file

Returns:

  • (Boolean)


52
53
54
# File 'lib/cabriolet/models/oab_header.rb', line 52

def full?
  !is_patch
end

#patch? ⇒ Boolean

Check if this is an incremental patch

Returns:

  • (Boolean)


45
46
47
# File 'lib/cabriolet/models/oab_header.rb', line 45

def patch?
  is_patch
end

#valid? ⇒ Boolean

Check if this is a valid OAB header

Returns:

  • (Boolean)


38
39
40
# File 'lib/cabriolet/models/oab_header.rb', line 38

def valid?
  version_hi == 3 && [1, 2].include?(version_lo)
end