1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Code::LOC: add #== and use it in Code#==

And fix a typo in comments.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
Kyrylo Silin 2013-01-07 01:44:49 +02:00
parent 13f8c1e688
commit 8a610e40f3
2 changed files with 8 additions and 5 deletions

View file

@ -264,7 +264,7 @@ class Pry
end
end
# Format output with a marker next to the given +lineno+, unless +line_num+
# Format output with a marker next to the given +lineno+, unless +lineno+
# is falsy.
#
# @param [Integer?] lineno
@ -357,10 +357,8 @@ class Pry
# @return [Boolean]
def ==(other)
if other.is_a?(Code)
@other_lines = other.instance_variable_get(:@lines)
@lines.each_with_index.all? do |loc, i|
loc.line == @other_lines[i].line && loc.lineno == @other_lines[i].lineno
end
other_lines = other.instance_variable_get(:@lines)
@lines.each_with_index.all? { |loc, i| loc == other_lines[i] }
else
to_s.chomp == other.to_s.chomp
end

View file

@ -28,6 +28,11 @@ class Pry
@tuple = [line.chomp, lineno.to_i]
end
# @return [Boolean]
def ==(other)
other.tuple == tuple
end
def dup
self.class.new(line, lineno)
end