Class: MarkdownToRspec::ToRspec::Item::Paragraph
- Defined in:
- lib/markdown_to_rspec/to_rspec/item/paragraph.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(text:, parent: nil, children: []) ⇒ Paragraph
constructor
A new instance of Paragraph.
Methods inherited from Base
Constructor Details
#initialize(text:, parent: nil, children: []) ⇒ Paragraph
Returns a new instance of Paragraph.
7 8 9 10 11 12 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 7 def initialize(text:, parent: nil, children: []) @text = text @parent = parent @children = children @depth = parent ? parent.depth + 1 : 0 end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
14 15 16 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 14 def children @children end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
14 15 16 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 14 def depth @depth end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
14 15 16 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 14 def parent @parent end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
14 15 16 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 14 def text @text end |
Instance Method Details
#convert ⇒ Object
16 17 18 19 |
# File 'lib/markdown_to_rspec/to_rspec/item/paragraph.rb', line 16 def convert lines = text.split("\n").map { |line| template(line) } lines.map { |line| indent(line) }.join("\n") end |