Class: Cabriolet::Models::CHMHeader

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

Overview

Represents a CHM file header and metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCHMHeader



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cabriolet/models/chm_header.rb', line 12

def initialize
  @filename = nil
  @version = 0
  @timestamp = 0
  @language = 0
  @length = 0
  @files = nil
  @sysfiles = nil
  @sec0 = CHMSecUncompressed.new(self)
  @sec1 = CHMSecMSCompressed.new(self)
  @dir_offset = 0
  @num_chunks = 0
  @chunk_size = 0
  @density = 0
  @depth = 0
  @index_root = 0
  @first_pmgl = 0
  @last_pmgl = 0
  @chunk_cache = nil
end

Instance Attribute Details

#chunk_cacheObject

Returns the value of attribute chunk_cache.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def chunk_cache
  @chunk_cache
end

#chunk_sizeObject

Returns the value of attribute chunk_size.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def chunk_size
  @chunk_size
end

#densityObject

Returns the value of attribute density.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def density
  @density
end

#depthObject

Returns the value of attribute depth.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def depth
  @depth
end

#dir_offsetObject

Returns the value of attribute dir_offset.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def dir_offset
  @dir_offset
end

#filenameObject

Returns the value of attribute filename.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def filename
  @filename
end

#filesObject

Returns the value of attribute files.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def files
  @files
end

#first_pmglObject

Returns the value of attribute first_pmgl.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def first_pmgl
  @first_pmgl
end

#index_rootObject

Returns the value of attribute index_root.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def index_root
  @index_root
end

#languageObject

Returns the value of attribute language.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def language
  @language
end

#last_pmglObject

Returns the value of attribute last_pmgl.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def last_pmgl
  @last_pmgl
end

#lengthObject

Returns the value of attribute length.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def length
  @length
end

#num_chunksObject

Returns the value of attribute num_chunks.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def num_chunks
  @num_chunks
end

#sec0Object

Returns the value of attribute sec0.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def sec0
  @sec0
end

#sec1Object

Returns the value of attribute sec1.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def sec1
  @sec1
end

#sysfilesObject

Returns the value of attribute sysfiles.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def sysfiles
  @sysfiles
end

#timestampObject

Returns the value of attribute timestamp.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def timestamp
  @timestamp
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/cabriolet/models/chm_header.rb', line 9

def version
  @version
end

Instance Method Details

#all_filesObject

Get all files as an array



34
35
36
37
38
39
40
41
42
# File 'lib/cabriolet/models/chm_header.rb', line 34

def all_files
  result = []
  file = files
  while file
    result << file
    file = file.next_file
  end
  result
end

#all_sysfilesObject

Get all system files as an array



45
46
47
48
49
50
51
52
53
# File 'lib/cabriolet/models/chm_header.rb', line 45

def all_sysfiles
  result = []
  file = sysfiles
  while file
    result << file
    file = file.next_file
  end
  result
end

#find_file(filename) ⇒ Object

Find a file by name



56
57
58
59
60
61
62
63
64
# File 'lib/cabriolet/models/chm_header.rb', line 56

def find_file(filename)
  file = files
  while file
    return file if file.filename == filename

    file = file.next_file
  end
  nil
end