Add #colorize.
This commit is contained in:
parent
0a2c394d02
commit
551279d5c2
|
@ -23,16 +23,15 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def colorize text
|
||||||
|
Pry.color ? CodeRay.scan(text.to_s, :ruby).term : text
|
||||||
|
end
|
||||||
|
|
||||||
def add_line_numbers(lines, start_line)
|
def add_line_numbers(lines, start_line)
|
||||||
line_array = lines.each_line.to_a
|
line_array = lines.each_line.to_a
|
||||||
line_array.each_with_index.map do |line, idx|
|
line_array.each_with_index.map do |line, idx|
|
||||||
adjusted_index = idx + start_line
|
adjusted_index = idx + start_line
|
||||||
if Pry.color
|
"#{colorize adjusted_index}: #{line}"
|
||||||
cindex = CodeRay.scan("#{adjusted_index}", :ruby).term
|
|
||||||
"#{cindex}: #{line}"
|
|
||||||
else
|
|
||||||
"#{idx}: #{line}"
|
|
||||||
end
|
|
||||||
end.join
|
end.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue