Class: Metanorma::Html::Component::IndexEntry
- Inherits:
-
Struct
- Object
- Struct
- Metanorma::Html::Component::IndexEntry
- Defined in:
- lib/metanorma/html/component/index_term_collector.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#locators ⇒ Object
Returns the value of attribute locators.
-
#see ⇒ Object
Returns the value of attribute see.
-
#see_also_entries ⇒ Object
Returns the value of attribute see_also_entries.
-
#term ⇒ Object
Returns the value of attribute term.
Instance Method Summary collapse
- #add_locator(id, text) ⇒ Object
- #add_see_also(term) ⇒ Object
- #find_or_add_child(term_name) ⇒ Object
-
#initialize ⇒ IndexEntry
constructor
A new instance of IndexEntry.
Constructor Details
#initialize ⇒ IndexEntry
Returns a new instance of IndexEntry.
71 72 73 74 75 76 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 71 def initialize(*) super self.locators ||= [] self.see_also_entries ||= [] self.children ||= [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children
69 70 71 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 69 def children @children end |
#locators ⇒ Object
Returns the value of attribute locators
69 70 71 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 69 def locators @locators end |
#see ⇒ Object
Returns the value of attribute see
69 70 71 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 69 def see @see end |
#see_also_entries ⇒ Object
Returns the value of attribute see_also_entries
69 70 71 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 69 def see_also_entries @see_also_entries end |
#term ⇒ Object
Returns the value of attribute term
69 70 71 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 69 def term @term end |
Instance Method Details
#add_locator(id, text) ⇒ Object
78 79 80 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 78 def add_locator(id, text) locators << IndexLocator.new(id: id, text: text) if id && !locators.any? { |l| l.id == id } end |
#add_see_also(term) ⇒ Object
82 83 84 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 82 def add_see_also(term) see_also_entries << term if term end |
#find_or_add_child(term_name) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/metanorma/html/component/index_term_collector.rb', line 86 def find_or_add_child(term_name) existing = children.find { |c| c.term.downcase == term_name.downcase } existing || begin child = IndexEntry.new(term: term_name) children << child child end end |