updated with_line_numbers method to accept color parameter

This commit is contained in:
John Mair 2011-08-06 08:50:32 +11:00
parent f25542a8af
commit 01b248e296
1 changed files with 10 additions and 10 deletions

View File

@ -67,11 +67,11 @@ class Pry
# @param [#each_line] text # @param [#each_line] text
# @param [Fixnum] offset # @param [Fixnum] offset
# @return [String] # @return [String]
def with_line_numbers text, offset def with_line_numbers(text, offset, color=:blue)
lines = text.each_line.to_a lines = text.each_line.to_a
lines.each_with_index.map do |line, index| lines.each_with_index.map do |line, index|
adjusted_index = index + offset adjusted_index = index + offset
"#{self.blue adjusted_index}: #{line}" "#{self.send(color, adjusted_index)}: #{line}"
end.join end.join
end end
end end