Class: Paperclip::ContentTypeDetector
- Inherits:
-
Object
- Object
- Paperclip::ContentTypeDetector
- Defined in:
- lib/paperclip/content_type_detector.rb
Constant Summary
- EMPTY_TYPE =
"inode/x-empty"- SENSIBLE_DEFAULT =
"application/octet-stream"
Instance Method Summary (collapse)
- - (Object) detect
-
- (ContentTypeDetector) initialize(filename)
constructor
A new instance of ContentTypeDetector.
Constructor Details
- (ContentTypeDetector) initialize(filename)
A new instance of ContentTypeDetector
6 7 8 |
# File 'lib/paperclip/content_type_detector.rb', line 6 def initialize(filename) @filename = filename end |
Instance Method Details
- (Object) detect
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/paperclip/content_type_detector.rb', line 10 def detect if blank_name? SENSIBLE_DEFAULT elsif empty_file? EMPTY_TYPE elsif !match? type_from_file_command elsif !multiple? possible_types.first else best_type_match end.to_s end |