Class: Rhombus
- Inherits:
-
Quadrilateral
- Object
- Polygon
- Quadrilateral
- Rhombus
- 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(arg = Hash.new(0)) ⇒ Rhombus
constructor
A new instance of Rhombus.
- #perimeter ⇒ Object
Methods inherited from Quadrilateral
Methods inherited from Polygon
Constructor Details
#initialize(arg = Hash.new(0)) ⇒ Rhombus
46 |
# File 'lib/shapedoc.rb', line 46 def initialize(arg = Hash.new(0)); @base, @height, @side = arg[:base], arg[:height], arg[:side]; end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
45 46 47 |
# File 'lib/shapedoc.rb', line 45 def base @base end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
45 46 47 |
# File 'lib/shapedoc.rb', line 45 def height @height end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
45 46 47 |
# File 'lib/shapedoc.rb', line 45 def side @side end |
Instance Method Details
#area ⇒ Object
47 |
# File 'lib/shapedoc.rb', line 47 def area; (@base*@height)/2; end |
#perimeter ⇒ Object
48 |
# File 'lib/shapedoc.rb', line 48 def perimeter; @side**2; end |