FileGroups
File extensions and media types, grouped by application and type.
Useful when you need to process or restrict processing to certain types of files.
Usage
Methods on FileGroups
return an object containing a set of media
types and file extensions. These are accessible via the .media_types
and .extensions
methods, which return an Array
of String
s. By default only commonly used values are returned.
To return all know values pass true
to either method, e.g., object.media_types(true)
In some cases additional methods can be called on the object to further restrict the set.
Let's look at some examples.
Images & Video
Retrieve a list of file extensions or media types used by images and video:
require "file_groups"
FileGroups.image.extensions
FileGroups.image.media_types
FileGroups.video.extensions
FileGroups.video.media_types
Images can be filtered on by raster, vector, or web:
FileGroups.image.web.extensions
FileGroups.image.raster.extensions
FileGroups.image.vector.extensions
For a complete list pass in true
to any of these methods:
FileGroups.image.web.extensions(true)
Spreadsheets
Retrieve a list of file extensions or media types used by spreadsheets:
require "file_groups"
FileGroups.spreadsheet.extensions
FileGroups.spreadsheet.media_types
If you only want values specific to CSVs:
FileGroups.spreadsheet.csv.media_types
If you only want values specific to Microsoft Excel:
FileGroups.spreadsheet.excel.extensions
FileGroups.spreadsheet.excel.media_types
Or for OpenOffice Calc:
FileGroups.spreadsheet.calc.extensions
By default these only return common extensions, to return all:
FileGroups.spreadsheet.excel.extensions(true)
Everything Else
See the list of categories and tags.
Author
Skye Shaw (skye.shaw -AT- gmail)
License
The gem is available as open source under the terms of the MIT License.