Class: Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Sodium
- Inherits:
-
Mindee::Parsing::Standard::FeatureField
- Object
- Mindee::Parsing::Standard::AbstractField
- Mindee::Parsing::Standard::FeatureField
- Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Sodium
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb
Overview
The amount of sodium in the product.
Instance Attribute Summary collapse
-
#daily_value ⇒ Float
readonly
DVs are the recommended amounts of sodium to consume or not to exceed each day.
-
#per_100g ⇒ Float
readonly
The amount of sodium per 100g of the product.
-
#per_serving ⇒ Float
readonly
The amount of sodium per serving of the product.
-
#unit ⇒ String
readonly
The unit of measurement for the amount of sodium.
Attributes inherited from Mindee::Parsing::Standard::AbstractField
#bounding_box, #confidence, #page_id, #polygon
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ NutritionFactsLabelV1Sodium
constructor
A new instance of NutritionFactsLabelV1Sodium.
- #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) ⇒ NutritionFactsLabelV1Sodium
Returns a new instance of NutritionFactsLabelV1Sodium.
26 27 28 29 30 31 32 33 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 26 def initialize(prediction, page_id) super(prediction, page_id) @daily_value = prediction['daily_value'] @per_100g = prediction['per_100g'] @per_serving = prediction['per_serving'] @unit = prediction['unit'] @page_id = page_id end |
Instance Attribute Details
#daily_value ⇒ Float (readonly)
DVs are the recommended amounts of sodium to consume or not to exceed each day.
13 14 15 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 13 def daily_value @daily_value end |
#per_100g ⇒ Float (readonly)
The amount of sodium per 100g of the product.
16 17 18 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 16 def per_100g @per_100g end |
#per_serving ⇒ Float (readonly)
The amount of sodium per serving of the product.
19 20 21 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 19 def per_serving @per_serving end |
#unit ⇒ String (readonly)
The unit of measurement for the amount of sodium.
22 23 24 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 22 def unit @unit end |
Instance Method Details
#printable_values ⇒ Hash
36 37 38 39 40 41 42 43 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 36 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[:unit] = format_for_display(@unit) printable end |
#to_s ⇒ String
46 47 48 49 50 51 52 53 54 |
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb', line 46 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 << "\n :Unit: #{printable[:unit]}" out_str end |