Class: MarkdownToRspec::ToRspec::Formatter::Markdown
- Inherits:
-
Object
- Object
- MarkdownToRspec::ToRspec::Formatter::Markdown
- Defined in:
- lib/markdown_to_rspec/to_rspec/formatter/markdown.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#parsed_markdown ⇒ Object
readonly
Returns the value of attribute parsed_markdown.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(markdown:) ⇒ Markdown
constructor
A new instance of Markdown.
Constructor Details
#initialize(markdown:) ⇒ Markdown
Returns a new instance of Markdown.
12 13 14 15 16 |
# File 'lib/markdown_to_rspec/to_rspec/formatter/markdown.rb', line 12 def initialize(markdown:) @markdown = markdown @parsed_markdown = RDoc::Markdown.parse(markdown) @items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
18 19 20 |
# File 'lib/markdown_to_rspec/to_rspec/formatter/markdown.rb', line 18 def items @items end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
18 19 20 |
# File 'lib/markdown_to_rspec/to_rspec/formatter/markdown.rb', line 18 def markdown @markdown end |
#parsed_markdown ⇒ Object (readonly)
Returns the value of attribute parsed_markdown.
18 19 20 |
# File 'lib/markdown_to_rspec/to_rspec/formatter/markdown.rb', line 18 def parsed_markdown @parsed_markdown end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/markdown_to_rspec/to_rspec/formatter/markdown.rb', line 20 def call parsed_markdown.parts.each do |part| item = format(part, find_parent(part)) @items << item end # Each item renders a child element, so only top-level items are converted. items.select { |item| item.parent.nil? }.map(&:convert).join("\n") end |