Class: Mindee::Product::BillOfLading::BillOfLadingV1CarrierItem
- Inherits:
-
Mindee::Parsing::Standard::FeatureField
- Object
- Mindee::Parsing::Standard::AbstractField
- Mindee::Parsing::Standard::FeatureField
- Mindee::Product::BillOfLading::BillOfLadingV1CarrierItem
- 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
-
#description ⇒ String
readonly
A description of the item.
-
#gross_weight ⇒ Float
readonly
The gross weight of the item.
-
#measurement ⇒ Float
readonly
The measurement of the item.
-
#measurement_unit ⇒ String
readonly
The unit of measurement for the measurement.
-
#quantity ⇒ Float
readonly
The quantity of the item being shipped.
-
#weight_unit ⇒ String
readonly
The unit of measurement for weights.
Attributes inherited from Mindee::Parsing::Standard::AbstractField
#bounding_box, #confidence, #page_id, #polygon
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ BillOfLadingV1CarrierItem
constructor
A new instance of BillOfLadingV1CarrierItem.
- #printable_values ⇒ Hash
- #table_printable_values ⇒ Hash
- #to_s ⇒ String
- #to_table_line ⇒ String
Methods inherited from Mindee::Parsing::Standard::FeatureField
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.
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
#description ⇒ String (readonly)
A description of the item.
13 14 15 |
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 13 def description @description end |
#gross_weight ⇒ Float (readonly)
The gross weight of the item.
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 |
#measurement ⇒ Float (readonly)
The measurement of the item.
19 20 21 |
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 19 def measurement @measurement end |
#measurement_unit ⇒ String (readonly)
The unit of measurement for the measurement.
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 |
#quantity ⇒ Float (readonly)
The quantity of the item being shipped.
25 26 27 |
# File 'lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb', line 25 def quantity @quantity end |
#weight_unit ⇒ String (readonly)
The unit of measurement for weights.
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_values ⇒ 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_values ⇒ 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_s ⇒ 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_line ⇒ 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 |