class MarkdownToRspec::ToRspec::Item::ListItem

Attributes

children[R]
depth[R]
parent[R]
text[R]

Public Class Methods

new(text:, parent: nil, children: []) click to toggle source
# File lib/markdown_to_rspec/to_rspec/item/list_item.rb, line 7
def initialize(text:, parent: nil, children: [])
  @text = text
  @parent = parent
  @children = children
  # The parent element(List), does not have a drawing element, so it inherits the parent's depth.
  @depth = parent ? parent.depth : 0
end

Public Instance Methods

convert() click to toggle source
# File lib/markdown_to_rspec/to_rspec/item/list_item.rb, line 17
def convert
  template(text).split("\n").map { |line| indent(line) }.join("\n")
end

Private Instance Methods

template(text) click to toggle source
# File lib/markdown_to_rspec/to_rspec/item/list_item.rb, line 23
        def template(text)
          <<~TEXT
            it '#{text.gsub("\n", ' ').gsub(/"|'/, '')}' do
            end
          TEXT
        end