Class: Asciidoctor::PDF::IndexTermGroup

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/asciidoctor/pdf/index_catalog.rb

Direct Known Subclasses

IndexTerm, IndexTermCategory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ IndexTermGroup

Returns a new instance of IndexTermGroup.



81
82
83
84
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 81

def initialize name
  @name = name
  @terms = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



79
80
81
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 79

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



96
97
98
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 96

def <=> other
  (val = @name.casecmp other.name) == 0 ? @name <=> other.name : val
end

#store_term(name, dest) ⇒ Object



86
87
88
89
90
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 86

def store_term name, dest
  term = (@terms[name] ||= (IndexTerm.new name))
  term.add_dest dest if dest
  term
end

#termsObject



92
93
94
# File 'lib/asciidoctor/pdf/index_catalog.rb', line 92

def terms
  @terms.empty? ? [] : @terms.values.sort
end