Class: RecipeScrapers::Models::Ingredient
- Inherits:
-
Data
- Object
- Data
- RecipeScrapers::Models::Ingredient
- Defined in:
- lib/recipe_scrapers/models/ingredient.rb
Overview
One ingredient line split into its parts. Recipe#parsed_ingredients holds these.
Instance Attribute Summary collapse
-
#amount ⇒ Float?
readonly
The quantity, rounded to two places.
-
#name ⇒ String?
readonly
The ingredient, without text in parentheses.
-
#unit ⇒ String?
readonly
The unit as the page writes it, such as "cups" or "g".
Instance Method Summary collapse
-
#initialize(amount: nil, unit: nil, name: nil) ⇒ Ingredient
constructor
A new instance of Ingredient.
Constructor Details
#initialize(amount: nil, unit: nil, name: nil) ⇒ Ingredient
Returns a new instance of Ingredient.
15 16 17 |
# File 'lib/recipe_scrapers/models/ingredient.rb', line 15 def initialize(amount: nil, unit: nil, name: nil) super end |
Instance Attribute Details
#amount ⇒ Float? (readonly)
Returns the quantity, rounded to two places. A range keeps its lower bound.
14 15 16 17 18 |
# File 'lib/recipe_scrapers/models/ingredient.rb', line 14 Ingredient = Data.define(:amount, :unit, :name) do def initialize(amount: nil, unit: nil, name: nil) super end end |
#name ⇒ String? (readonly)
Returns the ingredient, without text in parentheses.
14 15 16 17 18 |
# File 'lib/recipe_scrapers/models/ingredient.rb', line 14 Ingredient = Data.define(:amount, :unit, :name) do def initialize(amount: nil, unit: nil, name: nil) super end end |
#unit ⇒ String? (readonly)
Returns the unit as the page writes it, such as "cups" or "g".
14 15 16 17 18 |
# File 'lib/recipe_scrapers/models/ingredient.rb', line 14 Ingredient = Data.define(:amount, :unit, :name) do def initialize(amount: nil, unit: nil, name: nil) super end end |