Class: Docbook::Output::IndexCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/docbook/output/index_generator.rb

Overview

Collects all indexterms from a document for index generation

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ IndexCollector

Returns a new instance of IndexCollector.



7
8
9
10
# File 'lib/docbook/output/index_generator.rb', line 7

def initialize(document)
  @document = document
  @index_terms = []
end

Instance Method Details

#by_typeObject

Get indexterms grouped by type



20
21
22
23
24
25
26
27
28
# File 'lib/docbook/output/index_generator.rb', line 20

def by_type
  result = {}
  @index_terms.each do |term|
    type = term[:type] || "default"
    result[type] ||= []
    result[type] << term
  end
  result
end

#collectObject

Collect all indexterms from the document



13
14
15
16
17
# File 'lib/docbook/output/index_generator.rb', line 13

def collect
  @index_terms = []
  traverse_element(@document)
  @index_terms
end