Class: Parallelogram
- Inherits:
-
Quadrilateral
- Object
- Polygon
- Quadrilateral
- Parallelogram
- Defined in:
- lib/shapedoc.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
Attributes inherited from Polygon
Instance Method Summary collapse
- #area ⇒ Object
-
#initialize(args = Hash.new(0)) ⇒ Parallelogram
constructor
A new instance of Parallelogram.
- #perimeter ⇒ Object
Methods inherited from Quadrilateral
Methods inherited from Polygon
Constructor Details
#initialize(args = Hash.new(0)) ⇒ Parallelogram
Returns a new instance of Parallelogram.
89 |
# File 'lib/shapedoc.rb', line 89 def initialize(args = Hash.new(0)); @base, @height, @side = args[:base], args[:height], args[:side]; end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
88 89 90 |
# File 'lib/shapedoc.rb', line 88 def base @base end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
88 89 90 |
# File 'lib/shapedoc.rb', line 88 def height @height end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
88 89 90 |
# File 'lib/shapedoc.rb', line 88 def side @side end |
Instance Method Details
#area ⇒ Object
90 |
# File 'lib/shapedoc.rb', line 90 def area; @base*@height; end |
#perimeter ⇒ Object
91 |
# File 'lib/shapedoc.rb', line 91 def perimeter; @base*2+@side*2; end |