Skip to content

Commit

Permalink
add fetch metro rates
Browse files Browse the repository at this point in the history
  • Loading branch information
mithereal committed Jul 18, 2022
1 parent 04e5147 commit 5696406
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions lib/price.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,34 +150,31 @@ defmodule GasolinePrice do

[{_, _, newlist}] = List.delete_at(data, 0)

rates =
Enum.map(newlist, fn x ->
{_, _, rates} = x

{_, _, [type]} = List.first(rates)

rates =
List.delete_at(rates, 0)
|> Enum.map(fn {_, _, [rate]} ->
String.replace(rate, "$", "")
|> String.trim()
|> String.to_float()
end)

rates = %{
regular: Enum.at(rates, 0),
mid: Enum.at(rates, 1),
premium: Enum.at(rates, 2),
diesel: Enum.at(rates, 3)
}

{String.downcase(area), rates, String.downcase(type)}
end)
Enum.map(newlist, fn x ->
{_, _, rates} = x

{_, _, [type]} = List.first(rates)

rates =
List.delete_at(rates, 0)
|> Enum.map(fn {_, _, [rate]} ->
String.replace(rate, "$", "")
|> String.trim()
|> String.to_float()
end)

rates = %{
regular: Enum.at(rates, 0),
mid: Enum.at(rates, 1),
premium: Enum.at(rates, 2),
diesel: Enum.at(rates, 3)
}

{String.downcase(area), rates, String.downcase(type)}
end)
end)
|> Enum.map(fn rates ->

rates =
data =
data =
Enum.map(rates, fn x ->
{_, rates, time} = x
%MetroRates.Period{period: time, rates: rates}
Expand Down

0 comments on commit 5696406

Please sign in to comment.