Class: Pulo::Cube
- Inherits:
-
Object
- Object
- Pulo::Cube
- Includes:
- Figure3D
- Defined in:
- lib/pulo/figure/figure3d.rb
Instance Attribute Summary collapse
-
#face ⇒ Object
readonly
Returns the value of attribute face.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Attributes included from Figure3D
Instance Method Summary collapse
-
#initialize(length: nil, face: nil, volume: nil) ⇒ Cube
constructor
A new instance of Cube.
Methods included from Quantity_Checker
Constructor Details
#initialize(length: nil, face: nil, volume: nil) ⇒ Cube
Returns a new instance of Cube.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pulo/figure/figure3d.rb', line 37 def initialize(length: nil, face: nil, volume: nil) quantity_check [length,Length] ,[face,Square], [volume, Volume] raise 'Cube needs volume or face or length.' unless (length || volume || face) if volume @volume=volume @length=volume.rt(3) @face=Square.new(width: @length) elsif face @face=face @length=@face.width @volume=@face.area*@length elsif length @length=length @face=Square.new(width: @length) @volume=@face.area*@length end @surfacearea=@face.area*6 end |
Instance Attribute Details
#face ⇒ Object (readonly)
Returns the value of attribute face.
35 36 37 |
# File 'lib/pulo/figure/figure3d.rb', line 35 def face @face end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
35 36 37 |
# File 'lib/pulo/figure/figure3d.rb', line 35 def length @length end |