Class: Coradoc::Element::Inline::Citation

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/element/inline/citation.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(opts = {}) ⇒ Citation

Returns a new instance of Citation.



9
10
11
12
# File 'lib/coradoc/element/inline/citation.rb', line 9

def initialize(opts = {})
  @cross_reference = opts.fetch(:cross_reference, nil)
  @comment = opts.fetch(:comment, nil)
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



5
6
7
# File 'lib/coradoc/element/inline/citation.rb', line 5

def comment
  @comment
end

#cross_referenceObject

Returns the value of attribute cross_reference.



5
6
7
# File 'lib/coradoc/element/inline/citation.rb', line 5

def cross_reference
  @cross_reference
end

Instance Method Details

#to_adocObject



14
15
16
17
18
19
20
# File 'lib/coradoc/element/inline/citation.rb', line 14

def to_adoc
  adoc = "[.source]\n"
  adoc << @cross_reference.to_adoc if @cross_reference
  adoc << "\n" if @cross_reference && !@comment
  adoc << Coradoc::Generator.gen_adoc(@comment) if @comment
  adoc
end