Class: Geometry::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/geometry-bgw.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, width) ⇒ Rectangle

Returns a new instance of Rectangle.



60
61
62
63
# File 'lib/geometry-bgw.rb', line 60

def initialize(length, width)
  @length = length
  @width = width
end

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



58
59
60
# File 'lib/geometry-bgw.rb', line 58

def length
  @length
end

#widthObject

Returns the value of attribute width.



58
59
60
# File 'lib/geometry-bgw.rb', line 58

def width
  @width
end

Instance Method Details

#areaObject



65
66
67
# File 'lib/geometry-bgw.rb', line 65

def area
  @length * @width
end

#perimeterObject



69
70
71
# File 'lib/geometry-bgw.rb', line 69

def perimeter
  (@length * 2) + (@width * 2)
end