Class: Rhombus

Inherits:
Quadrilateral show all
Defined in:
lib/shapedoc.rb

Instance Attribute Summary collapse

Attributes inherited from Polygon

#sides

Instance Method Summary collapse

Methods inherited from Quadrilateral

#_sides

Methods inherited from Polygon

#_sides

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

#baseObject (readonly)

Returns the value of attribute base.



45
46
47
# File 'lib/shapedoc.rb', line 45

def base
  @base
end

#heightObject (readonly)

Returns the value of attribute height.



45
46
47
# File 'lib/shapedoc.rb', line 45

def height
  @height
end

#sideObject (readonly)

Returns the value of attribute side.



45
46
47
# File 'lib/shapedoc.rb', line 45

def side
  @side
end

Instance Method Details

#areaObject



47
# File 'lib/shapedoc.rb', line 47

def area; (@base*@height)/2; end

#perimeterObject



48
# File 'lib/shapedoc.rb', line 48

def perimeter; @side**2; end