Class: AsciidoctorBibliography::Database
- Inherits:
-
Array
- Object
- Array
- AsciidoctorBibliography::Database
- Defined in:
- lib/asciidoctor-bibliography/database.rb
Overview
This is an array of citeproc entries.
Class Method Summary collapse
Instance Method Summary collapse
- #append(filepath) ⇒ Object
- #find_entry_by_id(id) ⇒ Object
-
#initialize(*filepaths) ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize(*filepaths) ⇒ Database
Returns a new instance of Database.
8 9 10 11 12 |
# File 'lib/asciidoctor-bibliography/database.rb', line 8 def initialize(*filepaths) filepaths.each do |filepath| append filepath end end |
Class Method Details
.load(filepath) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/asciidoctor-bibliography/database.rb', line 29 def self.load(filepath) raise Errors::Database::FileNotFound, filepath unless File.exist?(filepath) fileext = File.extname filepath case fileext when *Databases::BibTeX::EXTENSIONS Databases::BibTeX.load filepath when *Databases::RFC::EXTENSIONS Databases::RFC.load filepath else raise Errors::Database::UnsupportedFormat, fileext end end |
Instance Method Details
#append(filepath) ⇒ Object
14 15 16 17 18 |
# File 'lib/asciidoctor-bibliography/database.rb', line 14 def append(filepath) concat Database.load(filepath) ensure_no_conflicts! self end |
#find_entry_by_id(id) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/asciidoctor-bibliography/database.rb', line 20 def find_entry_by_id(id) result = detect { |entry| entry["id"] == id } if result.nil? = "No entry with id '#{id}' was found in the bibliographic database." raise Errors::Database::IdNotFound, end result end |