Method: Propolize::ListChunk#getDocumentComponent

Defined in:
lib/propolize.rb

#getDocumentComponentObject



860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/propolize.rb', line 860

def getDocumentComponent
  itemList = ItemList.new(:isCritique => @isCritique)
  currentItemLines = nil
  # loop over lines
  for line in lines do
    itemStartMatch = line.match(/^\*\s+(.*)$/) # if a line starts with "* ", 
    if itemStartMatch  # we have found the start of a new item
      if currentItemLines != nil
        addItemToList(itemList, currentItemLines) # save the previous list item if any
      end
      currentItemLines = [itemStartMatch[1]] # start the new list of lines for this item
    else
      currentItemLines.push(line.strip) # add this line to the existing list of lines for the current list item
    end
  end
  if currentItemLines != nil
    addItemToList(itemList, currentItemLines) # save any final list item not yet saved
  end
  return itemList
end