Skip to content

Instantly share code, notes, and snippets.

icons = Hash.new
@vehicles.each do |v|
if !v.latest_position.nil?
icon = v.icon_id || 0
heading = v.latest_position.heading
if icons.has_key?(icon)
if icons[icon].has_key?(heading)
icons[icon][heading].push(v)
else
icons[icon][heading] = [v]