Skip to content

Instantly share code, notes, and snippets.

@bogardpd

bogardpd/map.rb

Created Sep 30, 2019
Embed
What would you like to do?
/app/classes/map.rb Routes
#/app/classes/map.rb
def gpx_routes(routes)
return nil unless routes.any?
routes = routes.map{|r| r.sort_by{|x| @airport_details[x][:iata]}}.uniq.sort_by{|y| [@airport_details[y[0]][:iata], @airport_details[y[1]][:iata]]}
return safe_join(routes.map{|r| gpx_route(r)})
end
def gpx_route(airport_pair)
detail = airport_pair.map{|a| @airport_details[a]}
return content_tag(:rte) do
concat content_tag(:name, detail.map{|a| a[:iata]}.join("–"))
concat content_tag(:desc, detail.map{|a| a[:city]}.join(" – "))
concat content_tag(:link, nil, href: "https://www.flighthistorian.com/routes/#{detail[0][:iata]}-#{detail[1][:iata]}")
concat safe_join(airport_pair.map{|a| gpx_airport(a, :rtept)})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.