Class: Geometry::Circle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r) ⇒ Circle

Returns a new instance of Circle.



37
38
39
40
# File 'lib/geometry-mc.rb', line 37

def initialize(r)
  @r = r
  @d = 2 * r
end

Instance Attribute Details

#rObject

Returns the value of attribute r.



35
36
37
# File 'lib/geometry-mc.rb', line 35

def r
  @r
end

Instance Method Details

#areaObject



42
43
44
# File 'lib/geometry-mc.rb', line 42

def area
  Math::PI * (@r ** 2)
end

#perimeterObject



46
47
48
# File 'lib/geometry-mc.rb', line 46

def perimeter
  Math::PI * @d
end