Module: Rectangle
- Includes:
- Dimensions
- Defined in:
- tomes/spells/geometry/rectangle.rb
Overview
A module for giving an object the properties of a rectangle.
Instance Attribute Summary
Attributes included from Size
Attributes included from Location
Instance Method Summary collapse
-
#area ⇒ Integer
Calculates the area of this rectangle.
-
#hypotenuse ⇒ Integer
Calculates the hypotenuse of this rectangle’s diagonal.
-
#perimeter ⇒ Integer
Calculates the perimeter of this rectangle.
Methods included from Dimensions
#change_dimensions, #dimensions, #rect
Methods included from Center
#horizontal_center, #true_center, #vertical_center
Methods included from Apex
Methods included from Size
Methods included from Location
#adjust_location, #location, #location=
Instance Method Details
#area ⇒ Integer
Calculates the area of this rectangle.
17 18 19 |
# File 'tomes/spells/geometry/rectangle.rb', line 17 def area width * height end |
#hypotenuse ⇒ Integer
Calculates the hypotenuse of this rectangle’s diagonal.
23 24 25 |
# File 'tomes/spells/geometry/rectangle.rb', line 23 def hypotenuse Math.sqrt((width**2) + (height**2)).round(0o2) end |
#perimeter ⇒ Integer
Calculates the perimeter of this rectangle.
11 12 13 |
# File 'tomes/spells/geometry/rectangle.rb', line 11 def perimeter (width * 2) + (height * 2) end |