Module: PerfectShape::RectangularShape
- Includes:
- PointLocation
- 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
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes included from PointLocation
Instance Method Summary collapse
-
#initialize(x: 0, y: 0, width: 1, height: 1) ⇒ Object
Calls super before setting x, y, width, height.
- #max_x ⇒ Object
- #max_y ⇒ Object
Methods included from PointLocation
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
30 31 32 |
# File 'lib/perfect_shape/rectangular_shape.rb', line 30 def height @height end |
#width ⇒ Object
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_x ⇒ Object
49 50 51 |
# File 'lib/perfect_shape/rectangular_shape.rb', line 49 def max_x @x + width if @x && width end |
#max_y ⇒ Object
53 54 55 |
# File 'lib/perfect_shape/rectangular_shape.rb', line 53 def max_y @y + height if @y && height end |