class ProceduralShape::Geometry

Constants

PI

Public Instance Methods

area(shape) click to toggle source
# File lib/shape/procedural_shape/geometry.rb, line 4
def area(shape)
  if shape.instance_of? Square
    shape.side * shape.side
  elsif shape.instance_of? Rectangle
    shape.height * shape.width
  elsif shape.instance_of? Circle
    (shape.radius * shape.radius) * PI
  end
end