Class: Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TotalFat
- Inherits:
-
Mindee::Parsing::Standard::FeatureField
- Object
- Mindee::Parsing::Standard::AbstractField
- Mindee::Parsing::Standard::FeatureField
- Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1TotalFat
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb
Overview
The total amount of fat in the product.
Instance Attribute Summary collapse
-
#daily_value ⇒ Float
readonly
DVs are the recommended amounts of total fat to consume or not to exceed each day.
-
#per_100g ⇒ Float
readonly
The amount of total fat per 100g of the product.
-
#per_serving ⇒ Float
readonly
The amount of total fat per serving of the product.
Attributes inherited from Mindee::Parsing::Standard::AbstractField
#bounding_box, #confidence, #page_id, #polygon
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ NutritionFactsLabelV1TotalFat
constructor
A new instance of NutritionFactsLabelV1TotalFat.
- #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) ⇒ NutritionFactsLabelV1TotalFat
Returns a new instance of NutritionFactsLabelV1TotalFat.
23 24 25 26 27 28 29 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 23 def initialize(prediction, page_id) super(prediction, page_id) @daily_value = prediction['daily_value'] @per_100g = prediction['per_100g'] @per_serving = prediction['per_serving'] @page_id = page_id end |
Instance Attribute Details
#daily_value ⇒ Float (readonly)
DVs are the recommended amounts of total fat to consume or not to exceed each day.
13 14 15 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 13 def daily_value @daily_value end |
#per_100g ⇒ Float (readonly)
The amount of total fat per 100g of the product.
16 17 18 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 16 def per_100g @per_100g end |
#per_serving ⇒ Float (readonly)
The amount of total fat per serving of the product.
19 20 21 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 19 def per_serving @per_serving end |
Instance Method Details
#printable_values ⇒ Hash
32 33 34 35 36 37 38 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 32 def printable_values printable = {} printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value) printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g) printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving) printable end |
#to_s ⇒ String
41 42 43 44 45 46 47 48 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb', line 41 def to_s printable = printable_values out_str = String.new out_str << "\n :Daily Value: #{printable[:daily_value]}" out_str << "\n :Per 100g: #{printable[:per_100g]}" out_str << "\n :Per Serving: #{printable[:per_serving]}" out_str end |