Class: MarkdownToRspec::ToRspec::Item::ListItem

Inherits:
Base
  • Object
show all
Defined in:
lib/markdown_to_rspec/to_rspec/item/list_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#indent

Constructor Details

#initialize(text:, parent: nil, children: []) ⇒ ListItem

Returns a new instance of ListItem.



7
8
9
10
11
12
13
# 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

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



15
16
17
# File 'lib/markdown_to_rspec/to_rspec/item/list_item.rb', line 15

def children
  @children
end

#depthObject (readonly)

Returns the value of attribute depth.



15
16
17
# File 'lib/markdown_to_rspec/to_rspec/item/list_item.rb', line 15

def depth
  @depth
end

#parentObject (readonly)

Returns the value of attribute parent.



15
16
17
# File 'lib/markdown_to_rspec/to_rspec/item/list_item.rb', line 15

def parent
  @parent
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'lib/markdown_to_rspec/to_rspec/item/list_item.rb', line 15

def text
  @text
end

Instance Method Details

#convertObject



17
18
19
# 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