Class: Pulo::Prism

Inherits:
Object
  • Object
show all
Includes:
Figure3D
Defined in:
lib/pulo/figure/figure3d.rb

Instance Attribute Summary collapse

Attributes included from Figure3D

#surfacearea, #volume

Instance Method Summary collapse

Methods included from Quantity_Checker

#quantity_check

Constructor Details

#initialize(face: nil, length: nil) ⇒ Prism



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/pulo/figure/figure3d.rb', line 135

def initialize(face: nil, length: nil)
  quantity_check [face,Triangle] ,[length,Length]
  raise 'Prism needs a face and length.' unless face && length
  @face=face
  @length=length
  @volume=@face.area*@length
  @side_areas=[]
  @side_areas[0]=@face.lengths[0]*@length
  @side_areas[1]=@face.lengths[1]*@length
  @side_areas[2]=@face.lengths[2]*@length
  @surfacearea=@face.area*2+@side_areas[0]+@side_areas[1]+@side_areas[2]
end

Instance Attribute Details

#faceObject (readonly)

Returns the value of attribute face.



133
134
135
# File 'lib/pulo/figure/figure3d.rb', line 133

def face
  @face
end

#lengthObject (readonly)

Returns the value of attribute length.



133
134
135
# File 'lib/pulo/figure/figure3d.rb', line 133

def length
  @length
end

#side_areasObject (readonly)

Returns the value of attribute side_areas.



134
135
136
# File 'lib/pulo/figure/figure3d.rb', line 134

def side_areas
  @side_areas
end