class Corraios::Containers::Package
Public Class Methods
valid_fields?(attributes)
click to toggle source
Calls superclass method
Corraios::Containers::Base::valid_fields?
# File lib/corraios/containers/package.rb, line 40 def valid_fields?(attributes) super(attributes) && (attributes[:width] + attributes[:height] + attributes[:length]) <= 200.0 end
Public Instance Methods
can_merge?(other)
click to toggle source
# File lib/corraios/containers/package.rb, line 12 def can_merge?(other) new_volume = self.volume + other.volume new_sides_size = (new_volume ** (1.0/3)) attributes = { weight: self.weight + other.weight } [:width, :length, :height].each do |attr| attributes[attr] = self.class.floor_for attr, new_sides_size end self.class.valid_fields? attributes end
merge!(other)
click to toggle source
# File lib/corraios/containers/package.rb, line 24 def merge!(other) self.weight += other.weight self.width = self.length = self.height = ((self.volume + other.volume) ** (1.0/3)) assert_minimum_measures! end
to_package()
click to toggle source
# File lib/corraios/containers/package.rb, line 34 def to_package self end
volume()
click to toggle source
# File lib/corraios/containers/package.rb, line 30 def volume width * length * height end