def transformed_by (other)
other = Geometry.parse(other) unless other.is_a? Geometry
return other.without_modifier if self =~ other || ['#', '!', '^'].include?(other.modifier)
raise TransformationError, "geometry is not transformable without both width and height" if self.height == 0 or self.width == 0
case other.modifier
when '>'
(other.width < self.width || other.height < self.height) ? scaled_to_fit(other) : self
when '<'
(other.width > self.width && other.height > self.height) ? scaled_to_fit(other) : self
when '%'
scaled_by(other)
when '@'
scaled_by(other.width * 100 / (self.width * self.height))
else
scaled_to_fit(other)
end
end