Skip to content

Instantly share code, notes, and snippets.

@vrootic
Created July 22, 2013 07:46
Show Gist options
  • Save vrootic/6052012 to your computer and use it in GitHub Desktop.
Save vrootic/6052012 to your computer and use it in GitHub Desktop.
def create_directory (records)
@dir = [] # Store all {container_object_id : [file_object_id]}
@container = [] # All content
@file = [] # [file_object_ids]
if records.respond_to?('each')
records.each do |record|
if record['container'] == nil && record['type'] == "container"
@container.push record['object_id']
end
if record['type'] == "file"
@file.push record
end
end
@container.each do |record|
tmp = {}
value_id = []
@file.each do |f|
if record == f['container']
value_id.push f['object_id']
end
end
tmp[record] = value_id
@dir.push tmp
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment