class Boxxer::Container

Attributes

contents[RW]
height[R]
length[R]
tare_weight[R]
width[R]

Public Class Methods

new(width:, height:, length:, tare_weight:, net_limit:) click to toggle source
# File lib/boxxer/container.rb, line 6
def initialize(width:, height:, length:, tare_weight:, net_limit:)
  @width = width
  @height = height
  @length = length
  @net_limit = net_limit
  @tare_weight = tare_weight
  @contents = []
end

Public Instance Methods

add_content(content) click to toggle source
# File lib/boxxer/container.rb, line 27
def add_content(content)
  @contents.push(content)
end
fittable?(weight) click to toggle source
# File lib/boxxer/container.rb, line 23
def fittable?(weight)
  @net_limit >= net_weight + weight
end
gross_weight() click to toggle source
# File lib/boxxer/container.rb, line 19
def gross_weight
  (net_weight + @tare_weight).truncate(3)
end
net_weight() click to toggle source
# File lib/boxxer/container.rb, line 15
def net_weight
  @contents.sum { |content| content[:weight] }.truncate(3)
end