Created
December 27, 2016 19:34
-
-
Save picatz/1553c090a070e98ad5f9820653d67f21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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