Class: Boxify::Container

Inherits:
Object
  • Object
show all
Includes:
Dimensionable
Defined in:
lib/boxify/container.rb

Instance Attribute Summary collapse

Attributes included from Dimensionable

#depth, #height, #width

Instance Method Summary collapse

Methods included from Dimensionable

#area, #surface_area, #volume

Constructor Details

#initialize(width:, depth:, height:) ⇒ Container

Returns a new instance of Container.



7
8
9
10
11
# File 'lib/boxify/container.rb', line 7

def initialize(width:, depth:, height:)
  @width = width
  @depth = depth
  @height = height
end

Instance Attribute Details

#placed_boxesObject

Returns the value of attribute placed_boxes.



5
6
7
# File 'lib/boxify/container.rb', line 5

def placed_boxes
  @placed_boxes
end

Instance Method Details

#volume_of_placed_boxesObject



13
14
15
# File 'lib/boxify/container.rb', line 13

def volume_of_placed_boxes
  placed_boxes.volume
end

#wasted_space_percentageObject



17
18
19
# File 'lib/boxify/container.rb', line 17

def wasted_space_percentage
  (volume - volume_of_placed_boxes).to_f / volume * 100
end