2013-07-09 21:40:21 +00:00
|
|
|
class Snapshot
|
2013-07-25 16:02:58 +00:00
|
|
|
|
2013-07-09 21:40:21 +00:00
|
|
|
attr_reader :lines
|
|
|
|
|
|
|
|
def initialize(lines = [])
|
|
|
|
@lines = lines
|
|
|
|
end
|
|
|
|
|
|
|
|
def ==(other)
|
|
|
|
other.lines == lines
|
|
|
|
end
|
|
|
|
|
2013-07-25 16:02:58 +00:00
|
|
|
def crop(width, height)
|
2013-07-25 17:39:27 +00:00
|
|
|
height = [height, lines.size].min
|
2013-07-25 16:02:58 +00:00
|
|
|
new_lines = lines.drop(lines.size - height).map { |line| line.crop(width) }
|
|
|
|
self.class.new(new_lines)
|
2013-07-09 21:40:21 +00:00
|
|
|
end
|
2013-07-25 16:02:58 +00:00
|
|
|
|
2013-07-09 21:40:21 +00:00
|
|
|
end
|