Skip to content

Instantly share code, notes, and snippets.

@msarit
Created August 21, 2019 00:16
Show Gist options
  • Select an option

  • Save msarit/a8aa9667832e3d50091e5d388e137ef1 to your computer and use it in GitHub Desktop.

Select an option

Save msarit/a8aa9667832e3d50091e5d388e137ef1 to your computer and use it in GitHub Desktop.
def build_page_data
current_id = nil
categories = {}
features = []
@page_data.each do |row|
if row[:group_id] != current_id
categories[current_id][:features] = features unless features.empty?
features = []
current_id = category[:group_id]
categories[category[:group_id]] = format_data(row)
end
features << features_hash(row)
end
categories[current_id][:features] = features unless features.empty?
categories
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment