class MarkdownToRspec::ToRspec::Formatter::ListItem

Attributes

rdoc_list_item[R]

Public Instance Methods

call(rdoc_list_item, parent) click to toggle source
# File lib/markdown_to_rspec/to_rspec/formatter/list_item.rb, line 7
def call(rdoc_list_item, parent)
  @rdoc_list_item = rdoc_list_item
  # We don't allow nesting of it, so we only get the first element.
  paragraph_text = find_paragraph.parts[0]
  list_item = ToRspec::Item::ListItem.new(text: paragraph_text, parent: parent)
  parent.children << list_item if parent
  list_item
end

Private Instance Methods

find_paragraph() click to toggle source
# File lib/markdown_to_rspec/to_rspec/formatter/list_item.rb, line 20
def find_paragraph
  check_paragraph = ->(obj) { obj.class.name == 'RDoc::Markup::Paragraph' }
  rdoc_list_item.parts.find(&check_paragraph)
end