Class: ProceduralShape::Geometry

Inherits:
Object
  • Object
show all
Defined in:
lib/shape/procedural_shape/geometry.rb

Constant Summary collapse

PI =
3.14

Instance Method Summary collapse

Instance Method Details

#area(shape) ⇒ Object



4
5
6
7
8
9
10
11
12
# 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