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

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

#baseObject (readonly)

Returns the value of attribute base.



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

def base
  @base
end

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

#sideObject (readonly)

Returns the value of attribute side.



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

def side
  @side
end

Instance Method Details

#areaObject



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

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

#perimeterObject



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

def perimeter; @side**2; end