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
#initialize(name, locale = nil) ⇒ IndexTermGroup
Returns a new instance of IndexTermGroup.
95
96
97
98
99
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 95
def initialize name, locale = nil
@name = name
@terms = {}
@locale = locale || 'en'
end
|
Instance Attribute Details
Returns the value of attribute name.
93
94
95
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 93
def name
@name
end
|
Instance Method Details
#<=>(other) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 111
def <=> other
if IndexTermCategory === self
@name <=> other.name
elsif (verdict = @name.casecmp other.name) == 0
other.name <=> @name
elsif (defined? ::ICU::Collation) && (!@name.ascii_only? || !other.name.ascii_only?)
(::ICU::Collation::Collator.new @locale).compare @name, other.name
else
verdict
end
end
|
#store_term(name, dest) ⇒ Object
101
102
103
104
105
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 101
def store_term name, dest
term = (@terms[name] ||= (IndexTerm.new name))
term.add_dest dest if dest
term
end
|
107
108
109
|
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 107
def terms
@terms.empty? ? [] : @terms.values.sort
end
|