Class: CiteProc::Bibliography

Inherits:
Object
  • Object
show all
Defined in:
lib/citeproc/bibliography.rb

Overview

A bibliography is an array of bibliographic entries and, optionally, a list of errors. The bibliography should be format agnostic; it is simply encapsulates two lists.

Instance Method Summary collapse

Constructor Details

#initialize(*args) {|_self| ... } ⇒ Bibliography

Returns a new instance of Bibliography.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
# File 'lib/citeproc/bibliography.rb', line 8

def initialize(*args)
  args.each { |argument| parse_argument(argument) }
  
  yield self if block_given?
end

Instance Method Details

#dataObject



14
# File 'lib/citeproc/bibliography.rb', line 14

def data; @data ||= []; end

#errorsObject



15
# File 'lib/citeproc/bibliography.rb', line 15

def errors; @errors ||= []; end

#optionsObject



16
# File 'lib/citeproc/bibliography.rb', line 16

def options; @options ||= {}; end

#to_jsonObject



25
26
27
# File 'lib/citeproc/bibliography.rb', line 25

def to_json
  [options.merge('bibliography-errors' => errors), data].to_json
end

#to_sObject



29
30
31
# File 'lib/citeproc/bibliography.rb', line 29

def to_s
  [options['bibstart'] || '<div class="csl-bib-body">', data.map { |d| "  <div class=\"csl-entry\">#{d}</div>" }, options['bibend'] || '</div>'].flatten.join("\n")
end