Class: Geometry::Rectangle
- Inherits:
-
Object
- Object
- Geometry::Rectangle
- Defined in:
- lib/geometry-mf.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #area ⇒ Object
-
#initialize(length, width) ⇒ Rectangle
constructor
A new instance of Rectangle.
- #perimeter ⇒ Object
Constructor Details
#initialize(length, width) ⇒ Rectangle
Returns a new instance of Rectangle.
33 34 35 36 |
# File 'lib/geometry-mf.rb', line 33 def initialize(length, width) @length = length @width = width end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
31 32 33 |
# File 'lib/geometry-mf.rb', line 31 def length @length end |
#width ⇒ Object
Returns the value of attribute width.
31 32 33 |
# File 'lib/geometry-mf.rb', line 31 def width @width end |
Instance Method Details
#area ⇒ Object
42 43 44 |
# File 'lib/geometry-mf.rb', line 42 def area @length * @width end |
#perimeter ⇒ Object
38 39 40 |
# File 'lib/geometry-mf.rb', line 38 def perimeter @length + @length + @width + @width end |