Class: Physical::Shipment

Inherits:
Object
  • Object
show all
Defined in:
lib/physical/shipment.rb

Overview

Represents a physical shipment containing structures and/or packages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, origin: nil, destination: nil, service_code: nil, pallets: [], structures: [], packages: [], options: {}) ⇒ Shipment

Returns a new instance of Shipment.

Parameters:

  • id (String) (defaults to: nil)

    a unique identifier for this shipment

  • origin (Physical::Location) (defaults to: nil)

    the shipment's origin location

  • destination (Physical::Location) (defaults to: nil)

    the shipment's destination location

  • service_code (String) (defaults to: nil)

    the shipment carrier's service code

  • pallets (Array<Physical::Pallet>) (defaults to: [])

    the shipment's pallets (DEPRECATED: use structures instead)

  • structures (Array<Physical::Structure>) (defaults to: [])

    the shipment's structures (pallets, skids, etc.) which hold packages

  • packages (Array<Physical::Package>) (defaults to: [])

    the shipment's packages (boxes) which hold items

  • options (Hash) (defaults to: {})

    additional custom options for this shipment



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/physical/shipment.rb', line 46

def initialize(id: nil, origin: nil, destination: nil, service_code: nil, pallets: [], structures: [], packages: [], options: {})
  @id = id || SecureRandom.uuid
  @origin = origin
  @destination = destination
  @service_code = service_code
  @structures = structures
  @packages = packages
  @options = options
  @pallets = pallets
  warn "[DEPRECATION] `pallets` is deprecated.  Please use `structures` instead." if pallets.any?
end

Instance Attribute Details

#destinationPhysical::Location (readonly)

This shipment's destination location

Returns:



16
17
18
# File 'lib/physical/shipment.rb', line 16

def destination
  @destination
end

#idString (readonly)

A unique identifier for this shipment

Returns:

  • (String)


8
9
10
# File 'lib/physical/shipment.rb', line 8

def id
  @id
end

#optionsHash (readonly)

Additional custom options for this shipment

Returns:

  • (Hash)


36
37
38
# File 'lib/physical/shipment.rb', line 36

def options
  @options
end

#originPhysical::Location (readonly)

This shipment's origin location

Returns:



12
13
14
# File 'lib/physical/shipment.rb', line 12

def origin
  @origin
end

#packagesArray<Physical::Package> (readonly)

This shipment's packages which hold items

Returns:



32
33
34
# File 'lib/physical/shipment.rb', line 32

def packages
  @packages
end

#palletsArray<Physical::Pallet> (readonly)

This shipment's pallets (DEPRECATED: use #structures instead)

Returns:



24
25
26
# File 'lib/physical/shipment.rb', line 24

def pallets
  @pallets
end

#service_codeString (readonly)

The shipment carrier's service code

Returns:

  • (String)


20
21
22
# File 'lib/physical/shipment.rb', line 20

def service_code
  @service_code
end

#structuresArray<Physical::Structure> (readonly)

This shipment's structures (pallets, skids, etc.) which hold packages

Returns:



28
29
30
# File 'lib/physical/shipment.rb', line 28

def structures
  @structures
end