Skip to content

Instantly share code, notes, and snippets.

@leejarvis

leejarvis/x.rb Secret

Created October 12, 2015 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejarvis/078c54c458d85d644069 to your computer and use it in GitHub Desktop.
Save leejarvis/078c54c458d85d644069 to your computer and use it in GitHub Desktop.
def all_groups
groups = []
time = nil
records.each do |record|
if time && (record.timestamp - time) > 12.hours || groups.empty?
groups << [record]
else
groups.last << record
end
time = record.timestamp
end
groups
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment