Class: Physical::Pallet
Overview
Represents a physical pallet which holds boxes.
Constant Summary collapse
- DEFAULT_LENGTH =
The default dimensions of this pallet when unspecified
BigDecimal::INFINITY
- DEFAULT_MAX_WEIGHT =
The default maximum weight of this pallet when unspecified
BigDecimal::INFINITY
Instance Attribute Summary collapse
-
#max_weight ⇒ Measured::Weight
readonly
The maximum weight this pallet can handle.
Attributes inherited from Cuboid
Instance Method Summary collapse
-
#dimensions ⇒ Array<Measured::Length>
(also: #inner_dimensions)
The dimensions of this pallet.
-
#height ⇒ Measured::Length
(also: #inner_height)
The height of this pallet.
-
#initialize(**kwargs) ⇒ Pallet
constructor
A new instance of Pallet.
-
#length ⇒ Measured::Length
(also: #inner_length)
The length of this pallet.
-
#package_fits?(package) ⇒ Boolean
Returns true if the given package can fit on the pallet.
-
#volume ⇒ Measured::Volume
(also: #inner_volume)
The volume of this pallet.
-
#width ⇒ Measured::Length
(also: #inner_width)
The width of this pallet.
Methods inherited from Cuboid
Constructor Details
#initialize(**kwargs) ⇒ Pallet
Returns a new instance of Pallet.
24 25 26 27 28 |
# File 'lib/physical/pallet.rb', line 24 def initialize(**kwargs) max_weight = kwargs.delete(:max_weight) || Measured::Weight(DEFAULT_MAX_WEIGHT, :g) super(**kwargs) @max_weight = Types::Weight[max_weight] end |
Instance Attribute Details
#max_weight ⇒ Measured::Weight (readonly)
The maximum weight this pallet can handle
16 17 18 |
# File 'lib/physical/pallet.rb', line 16 def max_weight @max_weight end |
Instance Method Details
#dimensions ⇒ Array<Measured::Length> Also known as: inner_dimensions
Returns the dimensions of this pallet.
36 |
# File 'lib/physical/pallet.rb', line 36 alias_method :inner_dimensions, :dimensions |
#height ⇒ Measured::Length Also known as: inner_height
Returns the height of this pallet.
48 |
# File 'lib/physical/pallet.rb', line 48 alias_method :inner_height, :height |
#length ⇒ Measured::Length Also known as: inner_length
Returns the length of this pallet.
40 |
# File 'lib/physical/pallet.rb', line 40 alias_method :inner_length, :length |
#package_fits?(package) ⇒ Boolean
Returns true if the given package can fit on the pallet. Checks package dimensions and weight against pallet dimensions and max weight.
54 55 56 57 58 59 60 61 62 |
# File 'lib/physical/pallet.rb', line 54 def package_fits?(package) return false if package.weight > max_weight pallet_dimensions = dimensions.sort package.dimensions.sort.each.with_index do |axis, index| return false if axis >= pallet_dimensions.sort[index] end true end |
#volume ⇒ Measured::Volume Also known as: inner_volume
Returns the volume of this pallet.
32 |
# File 'lib/physical/pallet.rb', line 32 alias_method :inner_volume, :volume |
#width ⇒ Measured::Length Also known as: inner_width
Returns the width of this pallet.
44 |
# File 'lib/physical/pallet.rb', line 44 alias_method :inner_width, :width |