Class: Docbook::Output::IndexCollector

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

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ IndexCollector

Returns a new instance of IndexCollector.



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

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

Instance Method Details

#by_typeObject



17
18
19
20
21
22
23
24
25
# File 'lib/docbook/output/index_generator.rb', line 17

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

#collectObject



11
12
13
14
15
# File 'lib/docbook/output/index_generator.rb', line 11

def collect
  @index_terms = []
  traverse(@document, {})
  @index_terms
end