Class: RecipeScrapers::Models::Nutrient

Inherits:
Data
  • Object
show all
Defined in:
lib/recipe_scrapers/models/nutrient.rb

Overview

One nutrition fact split into its parts. Recipe#parsed_nutrients holds these.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, unit: nil, amount: nil) ⇒ Nutrient

Returns a new instance of Nutrient.



14
15
16
# File 'lib/recipe_scrapers/models/nutrient.rb', line 14

def initialize(name: nil, unit: nil, amount: nil)
  super
end

Instance Attribute Details

#amount ⇒ Float? (readonly)

Returns the number, with every decimal the page writes.

Returns:

  • (Float, nil) —

    the number, with every decimal the page writes



13
14
15
16
17
# File 'lib/recipe_scrapers/models/nutrient.rb', line 13

Nutrient = Data.define(:name, :unit, :amount) do
  def initialize(name: nil, unit: nil, amount: nil)
    super
  end
end

#name ⇒ String? (readonly)

Returns the key the page uses, such as "calories" or "fatContent".

Returns:

  • (String, nil) —

    the key the page uses, such as "calories" or "fatContent"



13
14
15
16
17
# File 'lib/recipe_scrapers/models/nutrient.rb', line 13

Nutrient = Data.define(:name, :unit, :amount) do
  def initialize(name: nil, unit: nil, amount: nil)
    super
  end
end

#unit ⇒ String? (readonly)

Returns "g", "mg", "µg", "kcal" or "kJ" for mass and energy, any other unit as written.

Returns:

  • (String, nil) —

    "g", "mg", "µg", "kcal" or "kJ" for mass and energy, any other unit as written



13
14
15
16
17
# File 'lib/recipe_scrapers/models/nutrient.rb', line 13

Nutrient = Data.define(:name, :unit, :amount) do
  def initialize(name: nil, unit: nil, amount: nil)
    super
  end
end