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.



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

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.



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

def base
  @base
end

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

#sideObject (readonly)

Returns the value of attribute side.



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

def side
  @side
end

Instance Method Details

#areaObject



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

def area; @base*@height; end

#perimeterObject



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

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