Class: FFI::Chm::Struct::FulltextIndex
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- FFI::Chm::Struct::FulltextIndex
- Defined in:
- lib/ffi-chm/struct/fulltext_index.rb
Defined Under Namespace
Instance Method Summary collapse
- #leaf(offset) ⇒ Object
- #nodedata(offset, size = node_size) ⇒ Object
- #root ⇒ Object
- #single_leaf? ⇒ Boolean
- #wlc_params ⇒ Object
- #wlcs(leaf) ⇒ Object
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 |
#root ⇒ Object
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
57 58 59 |
# File 'lib/ffi-chm/struct/fulltext_index.rb', line 57 def single_leaf? self.depth == 1 end |
#wlc_params ⇒ Object
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 |