Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created September 17, 2016 06:34
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 anonymous/6db82eed90e85229c70195f26fde8ce1 to your computer and use it in GitHub Desktop.
Save anonymous/6db82eed90e85229c70195f26fde8ce1 to your computer and use it in GitHub Desktop.
def chunked
return enum_for(:each) unless block_given?
each.chunk(&:year).each do |year, timestamps|
yield year, timestamps.chunk(&:month)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment