lib/geometry/path.rb in geometry-6.5 vs lib/geometry/path.rb in geometry-6.6
- old
+ new
@@ -50,13 +50,40 @@
raise ArgumentError, "Unsupported argument type: #{n}"
end
end
end
+ def ==(other)
+ if other.is_a?(Path)
+ @elements == other.elements
+ else
+ super other
+ end
+ end
+
+ # @group Attributes
+
+ # @return [Point] The upper-right corner of the bounding rectangle that encloses the {Path}
+ def max
+ elements.reduce(elements.first.max) {|memo, e| memo.max(e.max) }
+ end
+
+ # @return [Point] The lower-left corner of the bounding rectangle that encloses the {Path}
+ def min
+ elements.reduce(elements.first.min) {|memo, e| memo.min(e.max) }
+ end
+
+ # @return [Array<Point>] The lower-left and upper-right corners of the enclosing bounding rectangle
+ def minmax
+ elements.reduce(elements.first.minmax) {|memo, e| [memo.first.min(e.min), memo.last.max(e.max)] }
+ end
+
# @return [Geometry] The last element in the {Path}
def last
@elements.last
end
+
+ # @endgroup
# Append a new geometry element to the {Path}
# @return [Path]
def push(arg)
@elements.push arg