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
Returns a new instance of Rhombus.
47 |
# File 'lib/shapedoc.rb', line 47 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.
46 47 48 |
# File 'lib/shapedoc.rb', line 46 def base @base end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
46 47 48 |
# File 'lib/shapedoc.rb', line 46 def height @height end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
46 47 48 |
# File 'lib/shapedoc.rb', line 46 def side @side end |
Instance Method Details
#area ⇒ Object
48 |
# File 'lib/shapedoc.rb', line 48 def area; (@base*@height)/2; end |
#perimeter ⇒ Object
49 |
# File 'lib/shapedoc.rb', line 49 def perimeter; @side**2; end |