Class: Geometry::Rectangle
- Inherits:
-
Object
- Object
- Geometry::Rectangle
- Defined in:
- lib/gemometry.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.
43 44 45 46 |
# File 'lib/gemometry.rb', line 43 def initialize(length, width) @length = length.to_f @width = width.to_f end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
41 42 43 |
# File 'lib/gemometry.rb', line 41 def length @length end |
#width ⇒ Object
Returns the value of attribute width.
41 42 43 |
# File 'lib/gemometry.rb', line 41 def width @width end |
Instance Method Details
#area ⇒ Object
52 53 54 |
# File 'lib/gemometry.rb', line 52 def area @length * @width end |
#perimeter ⇒ Object
48 49 50 |
# File 'lib/gemometry.rb', line 48 def perimeter 2 * (@length + @width) end |