lib/perfect_shape/shape.rb in perfect-shape-0.0.9 vs lib/perfect_shape/shape.rb in perfect-shape-0.0.10
- old
+ new
@@ -36,15 +36,19 @@
# Subclasses must implement
def max_y
end
- # Subclasses must implement
+ # Default implementation is max_x - min_x
+ # Subclasses can override
def width
+ max_x - min_x if max_x && min_x
end
- # Subclasses must implement
+ # Default implementation is max_y - min_y
+ # Subclasses can override
def height
+ max_y - min_y if max_y && min_y
end
# center_x is min_x + width/2.0 by default
# Returns nil if min_x or width are nil
def center_x