Class: Mindee::Product::BillOfLading::BillOfLadingV1CarrierItem

Inherits:
Mindee::Parsing::Standard::FeatureField show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb

Overview

The goods being shipped.

Instance Attribute Summary collapse

Attributes inherited from Mindee::Parsing::Standard::AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from Mindee::Parsing::Standard::FeatureField

#format_for_display

Methods inherited from Mindee::Parsing::Standard::AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id) ⇒ BillOfLadingV1CarrierItem

Returns a new instance of BillOfLadingV1CarrierItem.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


32
33
34
35
36
37
38
39
40
41
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 32

def initialize(prediction, page_id)
  super(prediction, page_id)
  @description = prediction['description']
  @gross_weight = prediction['gross_weight']
  @measurement = prediction['measurement']
  @measurement_unit = prediction['measurement_unit']
  @quantity = prediction['quantity']
  @weight_unit = prediction['weight_unit']
  @page_id = page_id
end

Instance Attribute Details

#descriptionString (readonly)

A description of the item.

Returns:

  • (String)


13
14
15
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 13

def description
  @description
end

#gross_weightFloat (readonly)

The gross weight of the item.

Returns:

  • (Float)


16
17
18
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 16

def gross_weight
  @gross_weight
end

#measurementFloat (readonly)

The measurement of the item.

Returns:

  • (Float)


19
20
21
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 19

def measurement
  @measurement
end

#measurement_unitString (readonly)

The unit of measurement for the measurement.

Returns:

  • (String)


22
23
24
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 22

def measurement_unit
  @measurement_unit
end

#quantityFloat (readonly)

The quantity of the item being shipped.

Returns:

  • (Float)


25
26
27
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 25

def quantity
  @quantity
end

#weight_unitString (readonly)

The unit of measurement for weights.

Returns:

  • (String)


28
29
30
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 28

def weight_unit
  @weight_unit
end

Instance Method Details

#printable_valuesHash

Returns:

  • (Hash)


44
45
46
47
48
49
50
51
52
53
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 44

def printable_values
  printable = {}
  printable[:description] = format_for_display(@description)
  printable[:gross_weight] = @gross_weight.nil? ? '' : Field.float_to_string(@gross_weight)
  printable[:measurement] = @measurement.nil? ? '' : Field.float_to_string(@measurement)
  printable[:measurement_unit] = format_for_display(@measurement_unit)
  printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
  printable[:weight_unit] = format_for_display(@weight_unit)
  printable
end

#table_printable_valuesHash

Returns:

  • (Hash)


56
57
58
59
60
61
62
63
64
65
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 56

def table_printable_values
  printable = {}
  printable[:description] = format_for_display(@description, 36)
  printable[:gross_weight] = @gross_weight.nil? ? '' : Field.float_to_string(@gross_weight)
  printable[:measurement] = @measurement.nil? ? '' : Field.float_to_string(@measurement)
  printable[:measurement_unit] = format_for_display(@measurement_unit, nil)
  printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
  printable[:weight_unit] = format_for_display(@weight_unit, nil)
  printable
end

#to_sString

Returns:

  • (String)


81
82
83
84
85
86
87
88
89
90
91
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 81

def to_s
  printable = printable_values
  out_str = String.new
  out_str << "\n  :Description: #{printable[:description]}"
  out_str << "\n  :Gross Weight: #{printable[:gross_weight]}"
  out_str << "\n  :Measurement: #{printable[:measurement]}"
  out_str << "\n  :Measurement Unit: #{printable[:measurement_unit]}"
  out_str << "\n  :Quantity: #{printable[:quantity]}"
  out_str << "\n  :Weight Unit: #{printable[:weight_unit]}"
  out_str
end

#to_table_lineString

Returns:

  • (String)


68
69
70
71
72
73
74
75
76
77
78
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 68

def to_table_line
  printable = table_printable_values
  out_str = String.new
  out_str << format('| %- 37s', printable[:description])
  out_str << format('| %- 13s', printable[:gross_weight])
  out_str << format('| %- 12s', printable[:measurement])
  out_str << format('| %- 17s', printable[:measurement_unit])
  out_str << format('| %- 9s', printable[:quantity])
  out_str << format('| %- 12s', printable[:weight_unit])
  out_str << '|'
end