Class: Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1ServingSize
- Inherits:
-
Mindee::Parsing::Standard::FeatureField
- Object
- Mindee::Parsing::Standard::AbstractField
- Mindee::Parsing::Standard::FeatureField
- Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1ServingSize
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb
Overview
The size of a single serving of the product.
Instance Attribute Summary collapse
-
#amount ⇒ Float
readonly
The amount of a single serving.
-
#unit ⇒ String
readonly
The unit for the amount of a single serving.
Attributes inherited from Mindee::Parsing::Standard::AbstractField
#bounding_box, #confidence, #page_id, #polygon
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ NutritionFactsLabelV1ServingSize
constructor
A new instance of NutritionFactsLabelV1ServingSize.
- #printable_values ⇒ Hash
- #to_s ⇒ 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) ⇒ NutritionFactsLabelV1ServingSize
Returns a new instance of NutritionFactsLabelV1ServingSize.
20 21 22 23 24 25 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb', line 20 def initialize(prediction, page_id) super(prediction, page_id) @amount = prediction['amount'] @unit = prediction['unit'] @page_id = page_id end |
Instance Attribute Details
#amount ⇒ Float (readonly)
The amount of a single serving.
13 14 15 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb', line 13 def amount @amount end |
#unit ⇒ String (readonly)
The unit for the amount of a single serving.
16 17 18 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb', line 16 def unit @unit end |
Instance Method Details
#printable_values ⇒ Hash
28 29 30 31 32 33 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb', line 28 def printable_values printable = {} printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount) printable[:unit] = format_for_display(@unit) printable end |
#to_s ⇒ String
36 37 38 39 40 41 42 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb', line 36 def to_s printable = printable_values out_str = String.new out_str << "\n :Amount: #{printable[:amount]}" out_str << "\n :Unit: #{printable[:unit]}" out_str end |