Class: FFI::Chm::Struct::FulltextIndex

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ffi-chm/struct/fulltext_index.rb

Defined Under Namespace

Classes: Index, Leaf

Instance Method Summary collapse

Instance Method Details

#leaf(offset) ⇒ Object



53
54
55
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 53

def leaf(offset)
  FFI::Chm::Struct::FulltextIndex::Leaf.new.read(self.nodedata(offset))
end

#nodedata(offset, size = node_size) ⇒ Object



49
50
51
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 49

def nodedata(offset, size=node_size)
  rest[offset - 1024, size]
end

#rootObject



61
62
63
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 61

def root
  @root ||= (single_leaf? ? Leaf : Index).new.read(self.nodedata(self.offset_to_root))
end

#single_leaf?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 57

def single_leaf?
  self.depth == 1
end

#wlc_paramsObject



65
66
67
68
69
70
71
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 65

def wlc_params
  {
    :document_root      => self.document_root,
    :code_count_root    => self.code_count_root,
    :location_code_root => self.location_code_root
  }
end

#wlcs(leaf) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 73

def wlcs(leaf)
  @wlcs ||= {}
  if @wlcs.has_key? leaf.offset_of_wlcs
    @wlcs[leaf.offset_of_wlcs]
  else
    data = BinData::IO.new self.nodedata(leaf.offset_of_wlcs, leaf.length_of_wlcs)
    @wlcs[leaf.offset_of_wlcs] = leaf.num_wlcs.times.map do
      FFI::Chm::Struct::WLC.new(self.wlc_params).read(data)
    end
  end
end