benjaminoakes/maid — pull request #88 by JohnColvin (2012-12-21 16:17:45+00:00)
Title: Added content_types method to pull from spotlight metadata

Using the kMDItemContentTypeTree spotlight metadata key, the content_types method gets an array of content types. These range from general to specific and allows for targeting general file groups like image, audio, archives, etc.

The "Organize Downloads" rule in my maid rules file shows how I use this. It's over here: [https://github.com/JohnColvin/.maid/blob/master/rules.rb](https://github.com/JohnColvin/.maid/blob/master/rules.rb)

Example image content_types array:
`["public.jpeg", "public.image", "public.data", "public.item", "public.content"]`

It uses the same cleaning as the raw output in `downloaded_from`. So, I extracted that code into a private method called `mdls_to_array`.