class Pulo::Rectangle

Attributes

height[R]
width[R]

Public Class Methods

new(area: nil, width: nil, height: nil) click to toggle source
# File lib/pulo/figure/figure2d.rb, line 69
def initialize(area: nil, width: nil, height: nil)
  quantity_check [area,Area] ,[width,Length] , [height,Length]
  raise 'Rectangle needs width and height or area and width or height.' unless (width && height) || (area && (width || height))
  if area
    @area=area
    if width
      @width=width; @height=@area/@width
    else
      @height=height; @width=@area/@height
    end
  else
    @width=width; @height=height
    @area=@width*@height
  end
  @perimeter=@width*2+@height*2
end

Public Instance Methods

extrusion_figure() click to toggle source
# File lib/pulo/figure/figure2d.rb, line 66
def extrusion_figure
  Cuboid
end