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.
29 lines
446 B
Ruby
29 lines
446 B
Ruby
class SnapshotFragment # TODO: rename to Cell or SnapshotCell
|
|
|
|
attr_reader :text, :brush
|
|
|
|
delegate :size, :to => :text
|
|
|
|
def initialize(text, brush)
|
|
@text = text
|
|
@brush = brush
|
|
end
|
|
|
|
def ==(other)
|
|
other.text == text && other.brush == brush
|
|
end
|
|
|
|
def crop(size)
|
|
if size >= text.size
|
|
self
|
|
else
|
|
self.class.new(text[0...size], brush)
|
|
end
|
|
end
|
|
|
|
def empty?
|
|
text.blank? && brush.default?
|
|
end
|
|
|
|
end
|