Class: MediaInformationGatherer::MediaType
- Inherits:
-
Object
- Object
- MediaInformationGatherer::MediaType
- Defined in:
- lib/mig/modules/media_type.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MediaType
constructor
A new instance of MediaType.
-
#run(file_path, options = { }) ⇒ Hash
Will contain :type, :subtype and any other attributes output during the call.
Constructor Details
#initialize(options = {}) ⇒ MediaType
Returns a new instance of MediaType.
6 |
# File 'lib/mig/modules/media_type.rb', line 6 def initialize( = {}); end |
Instance Method Details
#run(file_path, options = { }) ⇒ Hash
Returns Will contain :type, :subtype and any other attributes output during the call.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mig/modules/media_type.rb', line 11 def run(file_path, = { }) media_type, charset = (File.mime_type(file_path) || '').split(';') type, subtype = media_type.split('/') if media_type.is_a?(String) output = { :type => type, :subtype => subtype } param = charset.strip.split('=') if charset.is_a?(String) output[param.first] = param.last if param.is_a?(Array) output end |