Class: PolymorphicShape::Rectangle
- Defined in:
- lib/shape/polymorphic_shape/rectangle.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #area ⇒ Object
-
#initialize(height, width) ⇒ Rectangle
constructor
A new instance of Rectangle.
Constructor Details
#initialize(height, width) ⇒ Rectangle
4 5 6 7 |
# File 'lib/shape/polymorphic_shape/rectangle.rb', line 4 def initialize(height, width) @height = height @width = width end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/shape/polymorphic_shape/rectangle.rb', line 3 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/shape/polymorphic_shape/rectangle.rb', line 3 def width @width end |
Instance Method Details
#area ⇒ Object
9 10 11 |
# File 'lib/shape/polymorphic_shape/rectangle.rb', line 9 def area @height * @width end |