Class: Glossarist::Collections::NonVerbalCollection
- Inherits:
-
Lutaml::Model::Collection
- Object
- Lutaml::Model::Collection
- Glossarist::Collections::NonVerbalCollection
- Defined in:
- lib/glossarist/collections/non_verbal_collection.rb
Overview
Generic collection for dataset-level non-verbal entities (Figure, Table, Formula). Provides by_id lookup across top-level entities and recursive subfigures (for Figure).
Subclasses declare the entity type via ‘instances`.
Direct Known Subclasses
Instance Method Summary collapse
-
#by_id(target_id) ⇒ NonVerbalEntity?
Find an entity by ID, searching recursively (Figure subfigures).
- #entries ⇒ Object
-
#exists?(id) ⇒ Boolean
Check if an entity with the given ID exists.
-
#ids ⇒ Set<String>
All entity IDs including sub-entity IDs (for Figure subfigures).
-
#store(entity) ⇒ Object
(also: #<<)
Store an entity.
Instance Method Details
#by_id(target_id) ⇒ NonVerbalEntity?
Find an entity by ID, searching recursively (Figure subfigures).
15 16 17 18 19 20 21 |
# File 'lib/glossarist/collections/non_verbal_collection.rb', line 15 def by_id(target_id) entries.each do |entity| found = entity.find_by_id(target_id) return found if found end nil end |
#entries ⇒ Object
46 47 48 |
# File 'lib/glossarist/collections/non_verbal_collection.rb', line 46 def entries @entries ||= [] end |
#exists?(id) ⇒ Boolean
Check if an entity with the given ID exists.
34 35 36 |
# File 'lib/glossarist/collections/non_verbal_collection.rb', line 34 def exists?(id) !by_id(id).nil? end |
#ids ⇒ Set<String>
All entity IDs including sub-entity IDs (for Figure subfigures).
26 27 28 |
# File 'lib/glossarist/collections/non_verbal_collection.rb', line 26 def ids Set.new(entries.flat_map(&:all_ids).compact) end |
#store(entity) ⇒ Object Also known as: <<
Store an entity.
41 42 43 |
# File 'lib/glossarist/collections/non_verbal_collection.rb', line 41 def store(entity) entries << entity end |