Class: Docbook::Output::IndexCollector
- Inherits:
-
Object
- Object
- Docbook::Output::IndexCollector
- Defined in:
- lib/docbook/output/index_generator.rb
Overview
Collects all indexterms from a document for index generation
Instance Method Summary collapse
-
#by_type ⇒ Object
Get indexterms grouped by type.
-
#collect ⇒ Object
Collect all indexterms from the document.
-
#initialize(document) ⇒ IndexCollector
constructor
A new instance of IndexCollector.
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_type ⇒ Object
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 |
#collect ⇒ Object
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 |