Class: Boxify::PlacedBoxCollection
- Inherits:
-
Object
- Object
- Boxify::PlacedBoxCollection
- Defined in:
- lib/boxify/placed_box.rb
Instance Attribute Summary collapse
-
#placed_boxes ⇒ Object
Returns the value of attribute placed_boxes.
Instance Method Summary collapse
- #add(box:, level:) ⇒ Object
-
#initialize(placed_boxes: []) ⇒ PlacedBoxCollection
constructor
A new instance of PlacedBoxCollection.
- #volume ⇒ Object
Constructor Details
#initialize(placed_boxes: []) ⇒ PlacedBoxCollection
Returns a new instance of PlacedBoxCollection.
19 20 21 |
# File 'lib/boxify/placed_box.rb', line 19 def initialize(placed_boxes: []) @placed_boxes = placed_boxes end |
Instance Attribute Details
#placed_boxes ⇒ Object
Returns the value of attribute placed_boxes.
17 18 19 |
# File 'lib/boxify/placed_box.rb', line 17 def placed_boxes @placed_boxes end |
Instance Method Details
#add(box:, level:) ⇒ Object
23 24 25 |
# File 'lib/boxify/placed_box.rb', line 23 def add(box:, level:) @placed_boxes.push(PlacedBox.new(box: box, level: level)) end |
#volume ⇒ Object
27 28 29 |
# File 'lib/boxify/placed_box.rb', line 27 def volume placed_boxes.map(&:volume).inject(:+) end |