Method: Lazydoc::Comment#parse_down
- Defined in:
- lib/lazydoc/comment.rb
#parse_down(str, lines = nil, skip_subject = true) ⇒ Object
Like parse_up but builds the content of self by parsing comments down from line_number. Parsing begins immediately after line_number (no whitespace lines are skipped). Previous content is overridden. Returns self.
document = %Q{
# == Section One
# documentation for section one
# 'with' + 'indentation'
#
# == Section Two
# documentation for section two
}
c = Comment.new 1
c.parse_down(document) {|line| line =~ /Section Two/}
c.comment # => "documentation for section one\n 'with' + 'indentation'"
c = Comment.new /Section Two/
c.parse_down(document)
c.line_number # => 5
c.comment # => "documentation for section two"
262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/lazydoc/comment.rb', line 262 def parse_down(str, lines=nil, skip_subject=true) parse(str, lines) do |n, comment_lines| # skip the subject line n += 1 if skip_subject # put together the comment while line = comment_lines[n] break if block_given? && yield(line) break unless append(line) n += 1 end end end |