Module: PerfectShape::RectangularShape

Includes:
PointLocation
Included in:
Arc, Rectangle
Defined in:
lib/perfect_shape/rectangular_shape.rb

Overview

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

Instance Attribute Summary collapse

Attributes included from PointLocation

#x, #y

Instance Method Summary collapse

Methods included from PointLocation

#first_point, #min_x, #min_y

Instance Attribute Details

#heightObject

Returns the value of attribute height.



30
31
32
# File 'lib/perfect_shape/rectangular_shape.rb', line 30

def height
  @height
end

#widthObject

Returns the value of attribute width.



30
31
32
# File 'lib/perfect_shape/rectangular_shape.rb', line 30

def width
  @width
end

Instance Method Details

#initialize(x: 0, y: 0, width: 1, height: 1) ⇒ Object

Calls super before setting x, y, width, height



33
34
35
36
37
# 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

#max_xObject



49
50
51
# File 'lib/perfect_shape/rectangular_shape.rb', line 49

def max_x
  @x + width if @x && width
end

#max_yObject



53
54
55
# File 'lib/perfect_shape/rectangular_shape.rb', line 53

def max_y
  @y + height if @y && height
end