Class: Geometry::Rectangle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(l, w) ⇒ Rectangle

Returns a new instance of Rectangle.



55
56
57
58
# File 'lib/geometry-mc.rb', line 55

def initialize(l, w)
  @l = l
  @w = w
end

Instance Attribute Details

#lObject

Returns the value of attribute l.



53
54
55
# File 'lib/geometry-mc.rb', line 53

def l
  @l
end

#wObject

Returns the value of attribute w.



53
54
55
# File 'lib/geometry-mc.rb', line 53

def w
  @w
end

Instance Method Details

#areaObject



64
65
66
# File 'lib/geometry-mc.rb', line 64

def area
  @l * @w
end

#perimeterObject



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

def perimeter
  2 * (@l + @w)
end