Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/method_source/code_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ def extract_first_expression(lines, consume=0, &block)
# @param [Array<String>] lines
# @return [String]
def extract_last_comment(lines)
buffer = ""
buffer = []

lines.each do |line|
# Add any line that is a valid ruby comment,
# but clear as soon as we hit a non comment line.
lines.reverse_each do |line|
# Add any line that is a valid ruby comment, and stop as
# soon as we hit a non comment line.
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
buffer << line.lstrip
buffer.append(line.lstrip)
else
buffer.replace("")
break
end
end

buffer
buffer.reverse.join()
end

# An exception matcher that matches only subsets of SyntaxErrors that can be
Expand Down