Class: AsciidocBib::Citations
- Inherits:
-
Object
- Object
- AsciidocBib::Citations
- Includes:
- CitationUtils
- Defined in:
- lib/asciidoc-bib/citations.rb
Overview
Stores list of citations used in document.
Constant Summary
Constants included from CitationUtils
AsciidocBib::CitationUtils::CITATION, AsciidocBib::CitationUtils::CITATION_FULL
Instance Attribute Summary collapse
-
#cites_used ⇒ Object
readonly
List of citations.
Instance Method Summary collapse
-
#add_from_line(line) ⇒ Object
Given a line of text, extract any citations and include new citation references in current list.
-
#initialize ⇒ Citations
constructor
A new instance of Citations.
-
#sorted_cites(biblio) ⇒ Object
Return a list of citation references in document, sorted into order.
Methods included from CitationUtils
#arrange_authors, #author_chicago, #retrieve_citations
Constructor Details
#initialize ⇒ Citations
Returns a new instance of Citations.
11 12 13 |
# File 'lib/asciidoc-bib/citations.rb', line 11 def initialize @cites_used = [] end |
Instance Attribute Details
#cites_used ⇒ Object (readonly)
List of citations.
9 10 11 |
# File 'lib/asciidoc-bib/citations.rb', line 9 def cites_used @cites_used end |
Instance Method Details
#add_from_line(line) ⇒ Object
Given a line of text, extract any citations and include new citation references in current list.
17 18 19 20 21 22 |
# File 'lib/asciidoc-bib/citations.rb', line 17 def add_from_line line retrieve_citations(line).each do |citation| @cites_used += citation.cites.collect {|cite| cite.ref} end @cites_used.uniq! {|item| item.to_s} # only keep each reference once end |
#sorted_cites(biblio) ⇒ Object
Return a list of citation references in document, sorted into order.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/asciidoc-bib/citations.rb', line 25 def sorted_cites biblio @cites_used.sort_by do |ref| bibitem = biblio[ref] unless bibitem.nil? # extract the reference, and uppercase. # Remove { } from grouped names for sorting. = bibitem. if .nil? = bibitem.editor end ().collect {|s| s.upcase.gsub("{","").gsub("}","")} + [bibitem.year] else [ref] end end end |