Class: MarkdownToRspec::ToRspec::Item::List

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#indent

Constructor Details

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

Returns a new instance of List.



7
8
9
10
11
# File 'lib/markdown_to_rspec/to_rspec/item/list.rb', line 7

def initialize(parent: nil, children: [])
  @parent = parent
  @children = children
  @depth = parent ? parent.depth + 1 : 0
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



14
15
16
# File 'lib/markdown_to_rspec/to_rspec/item/list.rb', line 14

def children
  @children
end

#depthObject (readonly)

Returns the value of attribute depth.



13
14
15
# File 'lib/markdown_to_rspec/to_rspec/item/list.rb', line 13

def depth
  @depth
end

#parentObject (readonly)

Returns the value of attribute parent.



13
14
15
# File 'lib/markdown_to_rspec/to_rspec/item/list.rb', line 13

def parent
  @parent
end

Instance Method Details

#convertObject



16
17
18
# File 'lib/markdown_to_rspec/to_rspec/item/list.rb', line 16

def convert
  children.map(&:convert).join("\n")
end