Class: AsciidoctorBibliography::Bibliographer
- Inherits:
-
Object
- Object
- AsciidoctorBibliography::Bibliographer
- Defined in:
- lib/asciidoctor-bibliography/bibliographer.rb
Instance Attribute Summary collapse
-
#citations ⇒ Object
Returns the value of attribute citations.
-
#database ⇒ Object
Returns the value of attribute database.
-
#indices ⇒ Object
Returns the value of attribute indices.
-
#occurring_keys ⇒ Object
readonly
Returns the value of attribute occurring_keys.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #add_citation(citation) ⇒ Object
- #appearance_index_of(target, id) ⇒ Object
-
#initialize ⇒ Bibliographer
constructor
A new instance of Bibliographer.
Constructor Details
#initialize ⇒ Bibliographer
Returns a new instance of Bibliographer.
9 10 11 12 13 14 15 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 9 def initialize @options = {} @citations = [] @indices = [] @database = nil @occurring_keys = {} end |
Instance Attribute Details
#citations ⇒ Object
Returns the value of attribute citations.
3 4 5 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 3 def citations @citations end |
#database ⇒ Object
Returns the value of attribute database.
5 6 7 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 5 def database @database end |
#indices ⇒ Object
Returns the value of attribute indices.
4 5 6 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 4 def indices @indices end |
#occurring_keys ⇒ Object (readonly)
Returns the value of attribute occurring_keys.
6 7 8 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 6 def occurring_keys @occurring_keys end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 7 def @options end |
Instance Method Details
#add_citation(citation) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 17 def add_citation(citation) citations << citation # NOTE: Since we're rendering the whole (possibly composite) citation as missing - even if # NOTE: a single key is nil - we add none of them to the occurring keys to be rendered in indices. return if citation.any_missing_id?(self) citation.citation_items.group_by(&:target).each do |target, citation_items| @occurring_keys[target] ||= [] @occurring_keys[target].concat(citation_items.map(&:key)).uniq! end end |
#appearance_index_of(target, id) ⇒ Object
30 31 32 |
# File 'lib/asciidoctor-bibliography/bibliographer.rb', line 30 def appearance_index_of(target, id) @occurring_keys[target].index(id) + 1 end |