ExKcal.Recipe (ExKcal v0.0.8)
ExKcal.Recipe splits preparation task into the list of steps.
Link to this section Summary
Types
Known SI prefixes.
Type representing recipe.
Volume of substance and unit it is represented in.
Weight of substance and unit it is represented in.
Functions
Delete instance of ExKcal.Recipe.Step from ExKcal.Recipe by its index.
Construct new instance of ExKcal.Recipe struct.
Calculate total nutritional value of the ExKcal.Products used in the ExKcal.Recipe.
It returns kind of a special ExKcal.Product instance containing sum of all of the relevant fields, from all of the used
Products.
Total preparation time of the recipe.
Link to this section Types
si_prefix()
Specs
si_prefix() :: :Y | :Z | :E | :P | :T | :G | :M | :k | :h | :da | :d | :c | :m | :μ | :n | :p | :f | :a | :z | :y
Known SI prefixes.
Specs
t() :: %ExKcal.Recipe{steps: [ExKcal.Recipe.Step.t()]}
Type representing recipe.
volume()
Specs
volume() :: {float(), :l | :dl | :ml} | {nil, :none}
Volume of substance and unit it is represented in.
weight()
Specs
weight() :: {float(), :kg | :g | :mg | :μg} | {nil, :none}
Weight of substance and unit it is represented in.
Link to this section Functions
add_step(recipe, step)
Specs
add_step(t(), ExKcal.Recipe.Step.t()) :: t()
Add ExKcal.Recipe.Step to ExKcal.Recipe.
delete_step(recipe, step_index)
Specs
delete_step(t(), non_neg_integer()) :: t()
Delete instance of ExKcal.Recipe.Step from ExKcal.Recipe by its index.
new()
Specs
new() :: t()
Construct new instance of ExKcal.Recipe struct.
total_nutrition(recipe)
Specs
total_nutrition(t()) :: ExKcal.Product.t()
Calculate total nutritional value of the ExKcal.Products used in the ExKcal.Recipe.
It returns kind of a special ExKcal.Product instance containing sum of all of the relevant fields, from all of the used
Products.
Notes
- It won't recalculate
totalfields, it will sum their values.
total_time(recipe)
Specs
total_time(t()) :: ExKcal.Recipe.Time.t()
Total preparation time of the recipe.
Examples
iex> %ExKcal.Recipe{
...> steps: [
...> %ExKcal.Recipe.Step{
...> instructions: "",
...> notes: "",
...> products: %ExKcal.Products{map: %{}},
...> time: %ExKcal.Recipe.Time{hours: 0, minutes: 5, seconds: 42}
...> },
...> %ExKcal.Recipe.Step{
...> instructions: "",
...> notes: "",
...> products: %ExKcal.Products{map: %{}},
...> time: %ExKcal.Recipe.Time{hours: 0, minutes: 0, seconds: 10}
...> },
...> %ExKcal.Recipe.Step{
...> instructions: "",
...> notes: "",
...> products: %ExKcal.Products{map: %{}},
...> time: %ExKcal.Recipe.Time{hours: 1, minutes: 0, seconds: 1}
...> }
...> ]
...> } |> ExKcal.Recipe.total_time()
%ExKcal.Recipe.Time{hours: 1, minutes: 5, seconds: 53}