module PerfectShape::RectangularShape

Mixin Module for Rectangular Shapes (having x, y, width, height) Can only be mixed into a class extending Shape or another module

Attributes

height[R]
width[R]

Public Class Methods

new(x: 0, y: 0, width: 1, height: 1) click to toggle source

Calls super before setting x, y, width, height

Calls superclass method PerfectShape::PointLocation::new
# File lib/perfect_shape/rectangular_shape.rb, line 33
def initialize(x: 0, y: 0, width: 1, height: 1)
  super(x: x, y: y)
  self.width = width
  self.height = height
end

Public Instance Methods

height=(value) click to toggle source

Sets height, normalizing to BigDecimal

# File lib/perfect_shape/rectangular_shape.rb, line 45
def height=(value)
  @height = BigDecimal(value.to_s)
end
max_x() click to toggle source
# File lib/perfect_shape/rectangular_shape.rb, line 49
def max_x
  @x + width if @x && width
end
max_y() click to toggle source
# File lib/perfect_shape/rectangular_shape.rb, line 53
def max_y
  @y + height if @y && height
end
width=(value) click to toggle source

Sets width, normalizing to BigDecimal

# File lib/perfect_shape/rectangular_shape.rb, line 40
def width=(value)
  @width = BigDecimal(value.to_s)
end