Class: Glossarist::Validation::BibliographyIndex
- Inherits:
-
Object
- Object
- Glossarist::Validation::BibliographyIndex
- Defined in:
- lib/glossarist/validation/bibliography_index.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Class Method Summary collapse
- .build_from_concepts(concepts, dataset_path: nil) ⇒ Object
- .build_from_yaml(concepts, bibliography_yaml: nil, images_yaml: nil) ⇒ Object
Instance Method Summary collapse
- #anchors ⇒ Object
- #each_entry(&block) ⇒ Object
-
#initialize ⇒ BibliographyIndex
constructor
A new instance of BibliographyIndex.
- #register(anchor, source = nil) ⇒ Object
- #resolve?(anchor) ⇒ Boolean
Constructor Details
#initialize ⇒ BibliographyIndex
Returns a new instance of BibliographyIndex.
8 9 10 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 8 def initialize @entries = {} end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
6 7 8 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 6 def entries @entries end |
Class Method Details
.build_from_concepts(concepts, dataset_path: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 28 def self.build_from_concepts(concepts, dataset_path: nil) index = new concepts.each { |concept| index_concept_sources(index, concept) } index_bibliography_file(index, dataset_path) index_images_file(index, dataset_path) index end |
.build_from_yaml(concepts, bibliography_yaml: nil, images_yaml: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 38 def self.build_from_yaml(concepts, bibliography_yaml: nil, images_yaml: nil) index = new concepts.each { |concept| index_concept_sources(index, concept) } index_bib_from_yaml_string(index, bibliography_yaml) index_images_from_yaml_string(index, images_yaml) index end |
Instance Method Details
#anchors ⇒ Object
20 21 22 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 20 def anchors @entries.keys end |
#each_entry(&block) ⇒ Object
24 25 26 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 24 def each_entry(&block) @entries.each_value(&block) end |
#register(anchor, source = nil) ⇒ Object
12 13 14 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 12 def register(anchor, source = nil) @entries[normalize_anchor(anchor)] = { anchor: anchor, source: source } end |
#resolve?(anchor) ⇒ Boolean
16 17 18 |
# File 'lib/glossarist/validation/bibliography_index.rb', line 16 def resolve?(anchor) @entries.key?(normalize_anchor(anchor)) end |