Skip to content

Instantly share code, notes, and snippets.

@erkattak
Created January 11, 2012 15:08
Show Gist options
  • Save erkattak/1595100 to your computer and use it in GitHub Desktop.
Save erkattak/1595100 to your computer and use it in GitHub Desktop.
flattening a multidimensional hash
ALLOWED_TYPES = {
'pdf' => ['application/pdf', 'application/x-download'],
'image' => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'],
'text' => ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
'spreadsheet' => ['application/excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
}
ALLOWED_TYPES.map{ |g,s| s }.flatten # => ["application/pdf", "application/x-download", "image/jpg", "image/jpeg", "image/pjpeg", "image/png", "image/x-png", "image/gif", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment