Skip to content

Instantly share code, notes, and snippets.

@knewter
Created December 3, 2013 11:41
Show Gist options
  • Save knewter/7767826 to your computer and use it in GitHub Desktop.
Save knewter/7767826 to your computer and use it in GitHub Desktop.
Interactive Elixir (0.11.3-dev) - press Ctrl+C to exit (type h() ENTER for help)
*** ERROR: Shell process terminated! (^G to start new job) ***
=ERROR REPORT==== 3-Dec-2013::05:40:53 ===
Error in process <0.27.0> with exit value: {undef,[{elixir_scope,to_erl_env,[{'Elixir.Macro.Env','Elixir.CurrentWeather.YahooFetcher',<<69 bytes>>,11,{extract_temperature,1},nil,['Elixir.IEx','Elixir.Integer','Elixir.Kernel','Elixir.Kernel.Typespec','Elixir.Record'],[],[{'Elixir.Kernel'...
require IEx
defmodule CurrentWeather.YahooFetcher do
def fetch(woeid) do
body = get(woeid)
temp = extract_temperature(body)
temp
end
defp extract_temperature(body) do
# Put code here to extract the temperature from the xml
IEx.pry
end
defp get(woeid) do
{:ok, 200, _headers, client} = :hackney.get(url_for(woeid))
{:ok, body} = :hackney.body(client)
body
end
defp url_for(woeid) do
base_url <> woeid
end
defp base_url do
"http://weather.yahooapis.com/forecastrss?w="
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment