I’m doing web scrapping where I generate a list of smoothies.
Here is the final function :
def get_smoothies_recipe() do
smoothies =
get_smoothies_url()
|> get_smoothies_html_body()
|> Enum.map(fn body ->
%{name: name, ingredients: ingredients, directions: directions} = %{name: get_smoothie_name(body), ingredients: get_smoothie_ingredients(body), directions: get_smoothie_directions(body)}
end
)
{:ok, smoothies}
end
My problem is that my functions get_smoothie_name
, get_smoothie_ingredients
and get_smoothie_directions
all return a tuple {:ok, result}
.
Hence each element of my final smoothies
array looks like so:
%{
directions: {:ok,
["Cut banana into small pieces and place into the bowl of a blender. Add the soy milk, yogurt, flax seed meal, and honey. Blend on lowest speed until smooth, about 5 seconds. Gradually add the blueberries while continuing to blend on low. Once the blueberries have been incorporated, increase speed, and blend to desired consistency.\n "]},
ingredients: {:ok,
["1 frozen banana, thawed for 10 to 15 minutes",
"1/2 cup vanilla soy milk", "1 cup vanilla fat-free yogurt",
"1 1/2 teaspoons flax seed meal", "1 1/2 teaspoons honey",
"2/3 cup frozen blueberries", "Add all ingredients to list",
"Add all ingredients to list"]},
name: {:ok, "Heavenly Blueberry Smoothie"}
}
I want to get rid of those :ok
in my final return statement. How can I do that ?