Class: Mobi::Header::PalmDocHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/mobi/header/palm_doc_header.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PalmDocHeader

Initializes the PalmDOC header.

data - A StreamSlicer which starts at the PalmDOC header.

Returns self.



11
12
13
# File 'lib/mobi/header/palm_doc_header.rb', line 11

def initialize(data)
  @data = data
end

Instance Method Details

#compression_typeObject

The compression type.

Returns a Fixnum.



25
26
27
28
29
30
# File 'lib/mobi/header/palm_doc_header.rb', line 25

def compression_type
  { 1 => 'None',
    2 => 'PalmDOC',
    17480 => 'HUFF/CDIC'
  }.fetch(raw_compression_type)
end

#encryption_typeObject

The encryption type.

Returns a String.



64
65
66
67
68
69
# File 'lib/mobi/header/palm_doc_header.rb', line 64

def encryption_type
  { 0 => 'None',
    1 => 'Old MOBIpocket',
    2 => 'MOBIpocket'
  }.fetch(raw_encryption_type)
end

#raw_compression_typeObject

The compression type as returned from byte code.

Returns a Fixnum.



18
19
20
# File 'lib/mobi/header/palm_doc_header.rb', line 18

def raw_compression_type
  @compression_type ||= @data[0, 2].unpack('n*')[0]
end

#raw_encryption_typeObject

The encryption type as returned from byte code.

Returns a Fixnum



57
58
59
# File 'lib/mobi/header/palm_doc_header.rb', line 57

def raw_encryption_type
  @encryption_type ||= @data[12, 2].unpack('n*')[0]
end

#record_countObject

Number of PDB records used for the text of the book.

Returns a Fixnum.



42
43
44
# File 'lib/mobi/header/palm_doc_header.rb', line 42

def record_count
  @record_count ||= @data[8, 2].unpack('n*')[0]
end

#record_sizeObject

Maximum size of each record containing text. Note that this always returns 4096.

Returns a Fixnum.



50
51
52
# File 'lib/mobi/header/palm_doc_header.rb', line 50

def record_size
  @record_size ||= @data[10, 2].unpack('n*')[0]
end

#text_lengthObject

The uncompressed length of the entire text of the book.

Returns a Fixnum.



35
36
37
# File 'lib/mobi/header/palm_doc_header.rb', line 35

def text_length
  @text_length ||= @data[4, 4].unpack('N*')[0]
end