Class: Geometry::Rectangle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, width) ⇒ Rectangle

Returns a new instance of Rectangle.



61
62
63
64
# File 'lib/geometry-befr.rb', line 61

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

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



59
60
61
# File 'lib/geometry-befr.rb', line 59

def length
  @length
end

#widthObject

Returns the value of attribute width.



59
60
61
# File 'lib/geometry-befr.rb', line 59

def width
  @width
end

Instance Method Details

#areaObject



66
67
68
# File 'lib/geometry-befr.rb', line 66

def area
  @length * @width
end

#perimeterObject



70
71
72
# File 'lib/geometry-befr.rb', line 70

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