Class: Coradoc::Element::Paragraph
- Defined in:
- lib/coradoc/element/paragraph.rb
Instance Attribute Summary collapse
-
#anchor ⇒ Object
Returns the value of attribute anchor.
-
#content ⇒ Object
Returns the value of attribute content.
-
#tdsinglepara ⇒ Object
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
Methods inherited from Base
access_children, #children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(content, options = {}) ⇒ Paragraph
Returns a new instance of Paragraph.
8 9 10 11 12 13 14 15 |
# File 'lib/coradoc/element/paragraph.rb', line 8 def initialize(content, = {}) @content = content @id = .fetch(:id, nil) @anchor = Inline::Anchor.new(@id) if @id @title = .fetch(:title, nil) @attributes = .fetch(:attributes, nil) @tdsinglepara = .fetch(:tdsinglepara, nil) end |
Instance Attribute Details
#anchor ⇒ Object
Returns the value of attribute anchor.
4 5 6 |
# File 'lib/coradoc/element/paragraph.rb', line 4 def anchor @anchor end |
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/coradoc/element/paragraph.rb', line 4 def content @content end |
#tdsinglepara ⇒ Object
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
17 18 19 |
# File 'lib/coradoc/element/paragraph.rb', line 17 def id content&.first&.id&.to_s end |
#texts ⇒ Object
21 22 23 |
# File 'lib/coradoc/element/paragraph.rb', line 21 def texts content.map(&:content) end |
#to_adoc ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/coradoc/element/paragraph.rb', line 25 def to_adoc title = @title.nil? ? "" : ".#{Coradoc::Generator.gen_adoc(@title)}\n" anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n" attrs = @attributes.nil? ? "" : "#{@attributes.to_adoc}\n" if @tdsinglepara "#{title}#{anchor}" << Coradoc.strip_unicode(Coradoc::Generator.gen_adoc(@content)) else "\n\n#{title}#{anchor}#{attrs}" << Coradoc.strip_unicode(Coradoc::Generator.gen_adoc(@content)) << "\n\n" end end |