Class: Asciidoctor::PDF::IndexTermGroup
- Inherits:
-
Object
- Object
- Asciidoctor::PDF::IndexTermGroup
show all
- Includes:
- Comparable
- Defined in:
- lib/asciidoctor/pdf/index_catalog.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of IndexTermGroup.
112
113
114
115
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 112
def initialize name
@name = name
@terms = {}
end
|
Instance Attribute Details
Returns the value of attribute name.
110
111
112
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 110
def name
@name
end
|
Instance Method Details
#<=>(other) ⇒ Object
136
137
138
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 136
def <=> other
(val = @name.casecmp other.name) == 0 ? @name <=> other.name : val
end
|
#store_term(name, dest, assoc = {}) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 117
def store_term name, dest, assoc = {}
term = (@terms[name] ||= (IndexTerm.new name))
term.add_dest dest if dest
term.associations ||= {}
unless assoc.empty?
if !term.associations[:see] && (see = assoc[:see])
term.associations[:see] = see
end
if (see_also = assoc[:see_also])
(term.associations[:see_also] ||= []).concat see_also
end
end
term
end
|
132
133
134
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 132
def terms
@terms.empty? ? [] : @terms.values.sort
end
|