Class: Coradoc::Element::Bibliography

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/element/bibliography.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit

Constructor Details

#initialize(options = {}) ⇒ Bibliography

Returns a new instance of Bibliography.



6
7
8
9
10
11
# File 'lib/coradoc/element/bibliography.rb', line 6

def initialize(options = {})
  @id = options.fetch(:id, nil)
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
  @title = options.fetch(:title, nil)
  @entries = options.fetch(:entries,nil)
end

Instance Attribute Details

#entriesObject

Returns the value of attribute entries.



4
5
6
# File 'lib/coradoc/element/bibliography.rb', line 4

def entries
  @entries
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/coradoc/element/bibliography.rb', line 4

def id
  @id
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/coradoc/element/bibliography.rb', line 4

def title
  @title
end

Instance Method Details

#to_adocObject



13
14
15
16
17
18
19
20
21
# File 'lib/coradoc/element/bibliography.rb', line 13

def to_adoc
  adoc = "#{gen_anchor}\n"
  adoc << "[bibliography]"
  adoc << "== #{@title}\n\n"
  @entries.each do |entry|
    adoc << "#{entry.to_adoc}\n"
  end
  adoc
end