Class: Boxify::EligibleBox

Inherits:
Object
  • Object
show all
Defined in:
lib/boxify/eligible_box.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(boxes:, space:) ⇒ EligibleBox

Returns a new instance of EligibleBox.



6
7
8
9
# File 'lib/boxify/eligible_box.rb', line 6

def initialize(boxes:, space:)
  @boxes = boxes
  @space = space
end

Instance Attribute Details

#boxesObject (readonly)

Returns the value of attribute boxes.



4
5
6
# File 'lib/boxify/eligible_box.rb', line 4

def boxes
  @boxes
end

#spaceObject (readonly)

Returns the value of attribute space.



4
5
6
# File 'lib/boxify/eligible_box.rb', line 4

def space
  @space
end

Class Method Details

.find_all(boxes:, space:) ⇒ Object



11
12
13
# File 'lib/boxify/eligible_box.rb', line 11

def self.find_all(boxes:, space:)
  new(boxes: boxes, space: space).eligible_boxes
end

.find_best_fit(boxes:, space:) ⇒ Object



15
16
17
# File 'lib/boxify/eligible_box.rb', line 15

def self.find_best_fit(boxes:, space:)
  new(boxes: boxes, space: space).eligible_box_with_largest_volume
end

Instance Method Details

#eligible_box_with_largest_volumeObject



23
24
25
# File 'lib/boxify/eligible_box.rb', line 23

def eligible_box_with_largest_volume
  @eligible_box_with_largest_volume ||= find_box_with_largest_volume(eligible_boxes)
end

#eligible_boxesObject



19
20
21
# File 'lib/boxify/eligible_box.rb', line 19

def eligible_boxes
  @eligible_boxes ||= find_eligible_boxes
end