Class: FriendlyShipping::Services::UpsFreight::LabelDocumentOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/ups_freight/label_document_options.rb

Constant Summary collapse

DOCUMENT_TYPES =
{
  label: "30",
  ups_bol: "20",
  vics_bol: "21"
}.freeze
DOCUMENT_FORMATS =
{
  pdf: "01"
}.freeze
THERMAL_CODE =
{
  false => "01",
  true => "02"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format: :pdf, type: :label, size: "4x6", thermal: false, labels_per_page: 1) ⇒ LabelDocumentOptions

Returns a new instance of LabelDocumentOptions.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 24

def initialize(
  format: :pdf,
  type: :label,
  size: "4x6",
  thermal: false,
  labels_per_page: 1
)
  @format = format
  @type = type
  @length, @width = size.split('x').sort
  @thermal = thermal
  @labels_per_page = labels_per_page
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



7
8
9
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 7

def format
  @format
end

#lengthObject (readonly)

Returns the value of attribute length.



7
8
9
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 7

def length
  @length
end

#thermalObject (readonly)

Returns the value of attribute thermal.



7
8
9
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 7

def thermal
  @thermal
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 7

def type
  @type
end

#widthObject (readonly)

Returns the value of attribute width.



7
8
9
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 7

def width
  @width
end

Instance Method Details

#document_type_codeObject



42
43
44
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 42

def document_type_code
  DOCUMENT_TYPES.fetch(type)
end

#format_codeObject



38
39
40
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 38

def format_code
  DOCUMENT_FORMATS.fetch(format)
end

#labels_per_pageObject



50
51
52
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 50

def labels_per_page
  @labels_per_page.to_s
end

#thermal_codeObject



46
47
48
# File 'lib/friendly_shipping/services/ups_freight/label_document_options.rb', line 46

def thermal_code
  THERMAL_CODE.fetch(thermal)
end