Class: Geometry::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/gemometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#lengthObject

Returns the value of attribute length.



41
42
43
# File 'lib/gemometry.rb', line 41

def length
  @length
end

#widthObject

Returns the value of attribute width.



41
42
43
# File 'lib/gemometry.rb', line 41

def width
  @width
end

Instance Method Details

#areaObject



52
53
54
# File 'lib/gemometry.rb', line 52

def area
  @length * @width
end

#perimeterObject



48
49
50
# File 'lib/gemometry.rb', line 48

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