Class: RecipeScrapers::Models::Ingredient

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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.

Returns:

  • (Float, nil) —

    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.

Returns:

  • (String, nil) —

    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".

Returns:

  • (String, nil) —

    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