Class: SpaceCalculator

Inherits:
Object
  • Object
show all
Defined in:
backend/app/model/space_calculator.rb

Defined Under Namespace

Classes: Dimensions, LocationContainerLookup, LocationPacker, MissingDimensionException, UnsupportedUnitException

Constant Summary collapse

MAX_CONTAINERS_TO_PACK =
99999

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container_profile, locations) ⇒ SpaceCalculator

Returns a new instance of SpaceCalculator.



13
14
15
16
17
18
19
20
21
22
23
# File 'backend/app/model/space_calculator.rb', line 13

def initialize(container_profile, locations)
  @container_profile = container_profile
  @locations = locations
  @total_spaces_available = 0
  @total_containers_of_type = 0
  @locations_with_space = []
  @locations_without_space = []
  @uncalculatable_locations = []

  calculate
end

Instance Attribute Details

#unitsObject (readonly)

Returns the value of attribute units



11
12
13
# File 'backend/app/model/space_calculator.rb', line 11

def units
  @units
end

Instance Method Details

#to_hashObject



26
27
28
29
30
31
32
33
34
35
# File 'backend/app/model/space_calculator.rb', line 26

def to_hash
  {
    'container_profile' => {'ref' => @container_profile.uri},
    'total_spaces_available' => @total_spaces_available,
    'total_containers_of_type' => @total_containers_of_type,
    'locations_with_space' => @locations_with_space,
    'locations_without_space' => @locations_without_space,
    'uncalculatable_locations' => @uncalculatable_locations
  }
end