Class: Physical::Box
Constant Summary collapse
- DEFAULT_LENGTH =
BigDecimal::INFINITY
Instance Attribute Summary collapse
-
#inner_dimensions ⇒ Object
readonly
Returns the value of attribute inner_dimensions.
-
#inner_height ⇒ Object
readonly
Returns the value of attribute inner_height.
-
#inner_length ⇒ Object
readonly
Returns the value of attribute inner_length.
-
#inner_width ⇒ Object
readonly
Returns the value of attribute inner_width.
Attributes inherited from Cuboid
#dimensions, #height, #id, #length, #properties, #weight, #width
Instance Method Summary collapse
-
#initialize(inner_dimensions: [], **args) ⇒ Box
constructor
A new instance of Box.
- #inner_volume ⇒ Object
Methods inherited from Cuboid
Constructor Details
#initialize(inner_dimensions: [], **args) ⇒ Box
Returns a new instance of Box.
13 14 15 16 17 |
# File 'lib/physical/box.rb', line 13 def initialize(inner_dimensions: [], **args) super args @inner_dimensions = fill_dimensions(Types::Dimensions[inner_dimensions]) @inner_length, @inner_width, @inner_height = *@inner_dimensions end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Physical::Cuboid
Instance Attribute Details
#inner_dimensions ⇒ Object (readonly)
Returns the value of attribute inner_dimensions.
8 9 10 |
# File 'lib/physical/box.rb', line 8 def inner_dimensions @inner_dimensions end |
#inner_height ⇒ Object (readonly)
Returns the value of attribute inner_height.
8 9 10 |
# File 'lib/physical/box.rb', line 8 def inner_height @inner_height end |
#inner_length ⇒ Object (readonly)
Returns the value of attribute inner_length.
8 9 10 |
# File 'lib/physical/box.rb', line 8 def inner_length @inner_length end |
#inner_width ⇒ Object (readonly)
Returns the value of attribute inner_width.
8 9 10 |
# File 'lib/physical/box.rb', line 8 def inner_width @inner_width end |
Instance Method Details
#inner_volume ⇒ Object
19 20 21 22 23 24 |
# File 'lib/physical/box.rb', line 19 def inner_volume Measured::Volume( inner_dimensions.map { |d| d.convert_to(:cm).value }.reduce(1, &:*), :ml ) end |