Skip to content

Instantly share code, notes, and snippets.

@azuby
Created January 12, 2012 22:42
Show Gist options
  • Save azuby/1603613 to your computer and use it in GitHub Desktop.
Save azuby/1603613 to your computer and use it in GitHub Desktop.
def nearest_job
return nil unless location
company.jobs.each do |j|
if j.location
distance = j.location.distance_from(location)
shortest_distance ||= distance
if distance < shortest_distance
shortest_distance = distance
job = j
end
end
end
return job ||= nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment