Class: Physical::Pallet
Constant Summary collapse
- DEFAULT_LENGTH =
BigDecimal::INFINITY
- DEFAULT_MAX_WEIGHT =
BigDecimal::INFINITY
Instance Attribute Summary collapse
-
#max_weight ⇒ Object
readonly
Returns the value of attribute max_weight.
Attributes inherited from Cuboid
#dimensions, #height, #id, #length, #properties, #weight, #width
Instance Method Summary collapse
-
#initialize(**args) ⇒ Pallet
constructor
A new instance of Pallet.
- #package_fits?(package) ⇒ Boolean
Methods inherited from Cuboid
Constructor Details
#initialize(**args) ⇒ Pallet
Returns a new instance of Pallet.
12 13 14 15 16 |
# File 'lib/physical/pallet.rb', line 12 def initialize(**args) max_weight = args.delete(:max_weight) || Measured::Weight(DEFAULT_MAX_WEIGHT, :g) super(**args) @max_weight = Types::Weight[max_weight] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Physical::PropertyReaders
Instance Attribute Details
#max_weight ⇒ Object (readonly)
Returns the value of attribute max_weight.
10 11 12 |
# File 'lib/physical/pallet.rb', line 10 def max_weight @max_weight end |
Instance Method Details
#package_fits?(package) ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/physical/pallet.rb', line 26 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 |