class Pulo::Square

Attributes

width[R]

Public Class Methods

new(width: nil, area: nil) click to toggle source
# File lib/pulo/figure/figure2d.rb, line 48
def initialize(width: nil, area: nil)
  raise "Square needs area or width." unless (area || width)

  quantity_check [area,Area] ,[width,Length]
  if area
    @area=area; @width=@area.rt(2)
  else
    @width=width; @area=@width**2
  end
  @perimeter=@width*4
end