You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
326 B
Ruby
20 lines
326 B
Ruby
class Snapshot
|
|
|
|
attr_reader :lines
|
|
|
|
def initialize(lines = [])
|
|
@lines = lines
|
|
end
|
|
|
|
def ==(other)
|
|
other.lines == lines
|
|
end
|
|
|
|
def crop(width, height)
|
|
height = [height, lines.size].min
|
|
new_lines = lines.drop(lines.size - height).map { |line| line.crop(width) }
|
|
self.class.new(new_lines)
|
|
end
|
|
|
|
end
|