Class: Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1Cholesterol

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

Overview

The amount of cholesterol in the product.

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) ⇒ NutritionFactsLabelV1Cholesterol

Returns a new instance of NutritionFactsLabelV1Cholesterol.

Parameters:

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


23
24
25
26
27
28
29
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.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_valueFloat (readonly)

DVs are the recommended amounts of cholesterol to consume or not to exceed each day.

Returns:

  • (Float)


13
14
15
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb', line 13

def daily_value
  @daily_value
end

#per_100gFloat (readonly)

The amount of cholesterol per 100g of the product.

Returns:

  • (Float)


16
17
18
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb', line 16

def per_100g
  @per_100g
end

#per_servingFloat (readonly)

The amount of cholesterol per serving of the product.

Returns:

  • (Float)


19
20
21
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb', line 19

def per_serving
  @per_serving
end

Instance Method Details

#printable_valuesHash

Returns:

  • (Hash)


32
33
34
35
36
37
38
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.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_sString

Returns:

  • (String)


41
42
43
44
45
46
47
48
# File 'lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.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