Class: Parallelogram

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(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

#baseObject (readonly)

Returns the value of attribute base.



88
89
90
# File 'lib/shapedoc.rb', line 88

def base
  @base
end

#heightObject (readonly)

Returns the value of attribute height.



88
89
90
# File 'lib/shapedoc.rb', line 88

def height
  @height
end

#sideObject (readonly)

Returns the value of attribute side.



88
89
90
# File 'lib/shapedoc.rb', line 88

def side
  @side
end

Instance Method Details

#areaObject



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

def area; @base*@height; end

#perimeterObject



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

def perimeter; @base*2+@side*2; end