Skip to content

Instantly share code, notes, and snippets.

@picatz
Created December 27, 2016 19:34
Show Gist options
  • Save picatz/1553c090a070e98ad5f9820653d67f21 to your computer and use it in GitHub Desktop.
Save picatz/1553c090a070e98ad5f9820653d67f21 to your computer and use it in GitHub Desktop.
class CustomLogParser
# ... previous code
def timeline
return false unless any_data?
info = {}
@data.each do |d|
if info.keys.include?(d[:ip])
info[d[:ip]][:new] = d[:time]
else
info[d[:ip]] = { old: d[:time], new: d[:time] }
end
end
formatted_info = []
info.each do |i|
format = []
format << i[0]
format << i[1][:old]
format << i[1][:new]
formatted_info << format
end
formatted_info
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment