Class: RecipeScrapers::Models::Nutrient
- Inherits:
-
Data
- Object
- Data
- RecipeScrapers::Models::Nutrient
- 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
-
#amount ⇒ Float?
readonly
The number, with every decimal the page writes.
-
#name ⇒ String?
readonly
The key the page uses, such as "calories" or "fatContent".
-
#unit ⇒ String?
readonly
"g", "mg", "µg", "kcal" or "kJ" for mass and energy, any other unit as written.
Instance Method Summary collapse
-
#initialize(name: nil, unit: nil, amount: nil) ⇒ Nutrient
constructor
A new instance of Nutrient.
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.
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".
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.
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 |