Class: Coradoc::Element::Paragraph
- Inherits:
-
Object
- Object
- Coradoc::Element::Paragraph
- Defined in:
- lib/coradoc/element/paragraph.rb
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Returns the value of attribute anchor.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#tdsinglepara ⇒ Object
readonly
Returns the value of attribute tdsinglepara.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(content, options = {}) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #texts ⇒ Object
- #to_adoc ⇒ Object
Constructor Details
#initialize(content, options = {}) ⇒ Paragraph
Returns a new instance of Paragraph.
6 7 8 9 10 11 12 |
# File 'lib/coradoc/element/paragraph.rb', line 6 def initialize(content, = {}) @content = content @meta = .fetch(:meta, nil) id = .fetch(:id, nil) @anchor = Inline::Anchor.new(id) if id @tdsinglepara = .fetch(:tdsinglepara, nil) end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Returns the value of attribute anchor.
4 5 6 |
# File 'lib/coradoc/element/paragraph.rb', line 4 def anchor @anchor end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/coradoc/element/paragraph.rb', line 4 def content @content end |
#tdsinglepara ⇒ Object (readonly)
Returns the value of attribute tdsinglepara.
4 5 6 |
# File 'lib/coradoc/element/paragraph.rb', line 4 def tdsinglepara @tdsinglepara end |
Instance Method Details
#id ⇒ Object
14 15 16 |
# File 'lib/coradoc/element/paragraph.rb', line 14 def id content&.first&.id&.to_s end |
#texts ⇒ Object
18 19 20 |
# File 'lib/coradoc/element/paragraph.rb', line 18 def texts content.map(&:content) end |
#to_adoc ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/coradoc/element/paragraph.rb', line 22 def to_adoc anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n" if @tdsinglepara "#{anchor}" << Coradoc::Generator.gen_adoc(@content).strip else "\n\n#{anchor}" << Coradoc::Generator.gen_adoc(@content).strip << "\n\n" end end |