Class: Geometry::Circle
- Inherits:
-
Object
- Object
- Geometry::Circle
- Defined in:
- lib/geometry-mc.rb
Instance Attribute Summary collapse
-
#r ⇒ Object
Returns the value of attribute r.
Instance Method Summary collapse
- #area ⇒ Object
-
#initialize(r) ⇒ Circle
constructor
A new instance of Circle.
- #perimeter ⇒ Object
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
#r ⇒ Object
Returns the value of attribute r.
35 36 37 |
# File 'lib/geometry-mc.rb', line 35 def r @r end |
Instance Method Details
#area ⇒ Object
42 43 44 |
# File 'lib/geometry-mc.rb', line 42 def area Math::PI * (@r ** 2) end |
#perimeter ⇒ Object
46 47 48 |
# File 'lib/geometry-mc.rb', line 46 def perimeter Math::PI * @d end |